mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2025-12-15 08:34:43 +01:00
potentially gather installed mods
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { getMods, ModData } from '../../../utils/gamebanana'
|
||||
import { getInstalledMods, getMods, ModData } from '../../../utils/gamebanana'
|
||||
import { LoadingCircle } from './LoadingCircle'
|
||||
|
||||
import './ModList.css'
|
||||
@@ -11,7 +11,13 @@ interface IProps {
|
||||
}
|
||||
|
||||
interface IState {
|
||||
modList: ModData[]
|
||||
modList: ModData[] | null
|
||||
installedList:
|
||||
| {
|
||||
path: string
|
||||
info: unknown
|
||||
}[]
|
||||
| null
|
||||
}
|
||||
|
||||
export class ModList extends React.Component<IProps, IState> {
|
||||
@@ -20,11 +26,26 @@ export class ModList extends React.Component<IProps, IState> {
|
||||
|
||||
console.log('Getting')
|
||||
|
||||
this.state = {
|
||||
modList: null,
|
||||
installedList: null,
|
||||
}
|
||||
|
||||
this.downloadMod = this.downloadMod.bind(this)
|
||||
}
|
||||
|
||||
async componentDidMount() {
|
||||
if (this.props.mode === 'installed') return
|
||||
if (this.props.mode === 'installed') {
|
||||
const installedMods = await getInstalledMods()
|
||||
|
||||
console.log(installedMods)
|
||||
|
||||
this.setState({
|
||||
installedList: installedMods,
|
||||
})
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
const mods = await getMods(this.props.mode)
|
||||
|
||||
@@ -40,11 +61,14 @@ export class ModList extends React.Component<IProps, IState> {
|
||||
render() {
|
||||
return (
|
||||
<div className="ModList">
|
||||
{this.state && this.state.modList ? (
|
||||
{(this.state.modList && this.props.mode !== 'installed') ||
|
||||
(this.state.installedList && this.props.mode === 'installed') ? (
|
||||
<div className="ModListInner">
|
||||
{this.state.modList.map((mod: ModData) => (
|
||||
<ModTile mod={mod} key={mod.id} onClick={this.downloadMod} />
|
||||
))}
|
||||
{this.props.mode === 'installed'
|
||||
? this.state.installedList?.map((mod) => <></>)
|
||||
: this.state.modList?.map((mod: ModData) => (
|
||||
<ModTile mod={mod} key={mod.id} onClick={this.downloadMod} />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<LoadingCircle />
|
||||
|
||||
Reference in New Issue
Block a user