From 4f3952aeb1a12640c64946259cc54a408c72b9c3 Mon Sep 17 00:00:00 2001 From: SpikeHD Date: Sat, 23 Jul 2022 23:14:31 -0700 Subject: [PATCH] downloading (almost) and only show when migoto is set --- src/ui/Main.tsx | 32 ++++++++++++++++++------------ src/ui/Mods.tsx | 7 ++++++- src/ui/components/mods/ModList.tsx | 9 ++++++++- src/ui/components/mods/ModTile.tsx | 2 ++ src/utils/mods.ts | 1 + 5 files changed, 36 insertions(+), 15 deletions(-) create mode 100644 src/utils/mods.ts diff --git a/src/ui/Main.tsx b/src/ui/Main.tsx index 13109ec..1501de4 100644 --- a/src/ui/Main.tsx +++ b/src/ui/Main.tsx @@ -35,7 +35,7 @@ interface IState { miniDownloadsOpen: boolean downloadsOpen: boolean gameDownloadsOpen: boolean - moddingOpen: boolean + migotoSet: boolean } export class Main extends React.Component { @@ -47,7 +47,7 @@ export class Main extends React.Component { miniDownloadsOpen: false, downloadsOpen: false, gameDownloadsOpen: false, - moddingOpen: false, + migotoSet: false, } listen('lang_error', (payload) => { @@ -94,6 +94,10 @@ export class Main extends React.Component { async componentDidMount() { const cert_generated = await getConfigOption('cert_generated') + this.setState({ + migotoSet: !!(await getConfigOption('migoto_path')), + }) + if (!cert_generated) { // Generate the certificate await invoke('generate_ca_files', { @@ -129,17 +133,19 @@ export class Main extends React.Component { > downloads -
{ - // Create and dispatch a custom "openMods" event - const event = new CustomEvent('changePage', { detail: 'modding' }) - window.dispatchEvent(event) - }} - className="TopButton" - > - mods -
+ {this.state.migotoSet && ( +
{ + // Create and dispatch a custom "openMods" event + const event = new CustomEvent('changePage', { detail: 'modding' }) + window.dispatchEvent(event) + }} + className="TopButton" + > + mods +
+ )} {/*
this.setState({ gameDownloadsOpen: !this.state.gameDownloadsOpen })}> game
*/} diff --git a/src/ui/Mods.tsx b/src/ui/Mods.tsx index 237850b..50b9b20 100644 --- a/src/ui/Mods.tsx +++ b/src/ui/Mods.tsx @@ -1,5 +1,6 @@ import React from 'react' import DownloadHandler from '../utils/download' +import { ModData } from '../utils/gamebanana' import { ModHeader } from './components/mods/ModHeader' import { ModList } from './components/mods/ModList' import TopBar from './components/TopBar' @@ -46,6 +47,10 @@ export class Mods extends React.Component { return } + async addDownload(mod: ModData) { + console.log('Downloading:', mod.name) + } + async setCategory(value: string) { this.setState({ category: value, @@ -59,7 +64,7 @@ export class Mods extends React.Component { - + ) } diff --git a/src/ui/components/mods/ModList.tsx b/src/ui/components/mods/ModList.tsx index 159f580..a5159b0 100644 --- a/src/ui/components/mods/ModList.tsx +++ b/src/ui/components/mods/ModList.tsx @@ -7,6 +7,7 @@ import { ModTile } from './ModTile' interface IProps { mode: string + addDownload: (mod: ModData) => void } interface IState { @@ -16,6 +17,8 @@ interface IState { export class ModList extends React.Component { constructor(props: IProps) { super(props) + + this.downloadMod = this.downloadMod.bind(this) } async componentDidMount() { @@ -28,13 +31,17 @@ export class ModList extends React.Component { }) } + async downloadMod(mod: ModData) { + this.props.addDownload(mod) + } + render() { return (
{this.state && this.state.modList ? (
{this.state.modList.map((mod: ModData) => ( - + ))}
) : ( diff --git a/src/ui/components/mods/ModTile.tsx b/src/ui/components/mods/ModTile.tsx index a77920c..4ff27a9 100644 --- a/src/ui/components/mods/ModTile.tsx +++ b/src/ui/components/mods/ModTile.tsx @@ -8,6 +8,7 @@ import Download from '../../../resources/icons/download.svg' interface IProps { mod: ModData + onClick: (mod: ModData) => void } interface IState { @@ -31,6 +32,7 @@ export class ModTile extends React.Component { className="ModListItem" onMouseEnter={() => this.setState({ hover: true })} onMouseLeave={() => this.setState({ hover: false })} + onClick={() => this.props.onClick(mod)} > {mod.name} {mod.submitter.name} diff --git a/src/utils/mods.ts b/src/utils/mods.ts new file mode 100644 index 0000000..336ce12 --- /dev/null +++ b/src/utils/mods.ts @@ -0,0 +1 @@ +export {}