Fix some issues

This commit is contained in:
2026-02-04 16:47:54 -07:00
parent 1c540ad35b
commit fbe3feec9d
2 changed files with 182 additions and 165 deletions

View File

@@ -1,6 +1,6 @@
'use client'
import { useEffect, useRef, useState } from 'react'
import { useCallback, useEffect, useRef, useState } from 'react'
import Sidebar from './componets/Sidebar'
import './Globals.css'
import { DownloadProgress } from './types/DownloadProgress'
@@ -111,15 +111,21 @@ export default function RootLayout ({
})
}
function getVersionInfo (id: string | undefined): GameVersion | undefined {
const getVersionInfo = useCallback(
(id: string | undefined): GameVersion | undefined => {
if (!id) return undefined
return serverVersionList?.versions.find(v => v.id === id)
}
},
[serverVersionList]
)
function getGameInfo (game: number | undefined): Game | undefined {
const getGameInfo = useCallback(
(game: number | undefined): Game | undefined => {
if (!game) return undefined
return serverVersionList?.games.find(g => g.id === game)
}
},
[serverVersionList]
)
function getListOfGames (): Game[] {
if (!downloadedVersionsConfig?.list) return []
@@ -292,10 +298,8 @@ export default function RootLayout ({
return () => document.removeEventListener('contextmenu', handler)
}, [])
async function downloadVersions (
list: string[],
currentConfig: VersionsConfig
): Promise<void> {
const downloadVersions = useCallback(
async (list: string[], currentConfig: VersionsConfig): Promise<void> => {
if (list.length === 0) return
setSelectedVersionList([])
@@ -374,7 +378,9 @@ export default function RootLayout ({
setFadeOut(true)
setTimeout(() => setShowPopup(false), 200)
}
},
[getGameInfo, getVersionInfo, normalConfig]
)
useEffect(() => {
if (revisionCheck.current) return
@@ -404,7 +410,7 @@ export default function RootLayout ({
await downloadVersions(versionsToSelect, newConfig)
})()
}, [serverVersionList, downloadedVersionsConfig])
}, [serverVersionList, downloadedVersionsConfig, downloadVersions])
return (
<>

View File

@@ -50,7 +50,7 @@ export default function Settings () {
label='Allow sending notifications'
value={allowNotifications}
onChange={async () => {
while (normalConfig != null) {
if (!normalConfig) return
setAllowNotifications(!allowNotifications)
setNormalConfig({
...normalConfig,
@@ -59,15 +59,13 @@ export default function Settings () {
allowNotifications: !allowNotifications
}
})
writeNormalConfig({
await writeNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
allowNotifications: !allowNotifications
}
})
break
}
}}
title='This setting does as you expect, allow the launcher to send notifications for when stuff like downloading is done.'
/>
@@ -75,7 +73,7 @@ export default function Settings () {
label='Always show games in sidebar'
value={alwaysShowGamesInSidebar}
onChange={async () => {
while (normalConfig != null) {
if (!normalConfig) return
setAlwaysShowGamesInSidebar(!alwaysShowGamesInSidebar)
setNormalConfig({
...normalConfig,
@@ -84,15 +82,13 @@ export default function Settings () {
alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar
}
})
writeNormalConfig({
await writeNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar
}
})
break
}
}}
title="This setting will make it so when you are on a page like this, the games won't disappear."
/>
@@ -100,7 +96,7 @@ export default function Settings () {
label='Show Installs/Launch/Manage Buttons'
value={useLegacyInteractButtons}
onChange={async () => {
while (normalConfig != null) {
if (!normalConfig) return
setUseLegacyInteractButtons(!useLegacyInteractButtons)
setNormalConfig({
...normalConfig,
@@ -109,15 +105,13 @@ export default function Settings () {
useLegacyInteractButtons: !useLegacyInteractButtons
}
})
writeNormalConfig({
await writeNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
useLegacyInteractButtons: !useLegacyInteractButtons
}
})
break
}
}}
title='Enable the legacy method of using the installs/launch/manage buttons. In the future this setting may be removed so try and get used to the new method.'
/>
@@ -125,13 +119,22 @@ export default function Settings () {
label='Use wine when needed to launch games'
value={useWineOnUnixWhenNeeded}
onChange={async () => {
while (normalConfig != null) {
if (!normalConfig) return
setUseWineOnUnixWhenNeeded(!useWineOnUnixWhenNeeded)
normalConfig.settings.useWineOnUnixWhenNeeded =
!useWineOnUnixWhenNeeded
await writeNormalConfig(normalConfig)
break
setNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
useWineOnUnixWhenNeeded: !useWineOnUnixWhenNeeded
}
})
await writeNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
useWineOnUnixWhenNeeded: !useWineOnUnixWhenNeeded
}
})
}}
className={platform() == 'linux' ? '' : 'hidden'}
/>
@@ -142,12 +145,22 @@ export default function Settings () {
type='text'
value={wineOnUnixCommand}
onChange={async e => {
while (normalConfig != null) {
if (!normalConfig) return
setWineOnUnixCommand(e.target.value)
normalConfig.settings.wineOnUnixCommand = e.target.value
await writeNormalConfig(normalConfig)
break
setNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
wineOnUnixCommand: e.target.value
}
})
await writeNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
wineOnUnixCommand: e.target.value
}
})
}}
className={`input-field my-1 ${
platform() == 'linux' && useWineOnUnixWhenNeeded ? '' : 'hidden'
@@ -159,8 +172,8 @@ export default function Settings () {
className='ml-2 bg-(--col2) border border-(--col4) rounded-md'
value={theme}
onChange={async e => {
if (!normalConfig) return
const newTheme = parseInt(e.target.value)
while (normalConfig != null) {
setTheme(newTheme)
setNormalConfig({
...normalConfig,
@@ -169,15 +182,13 @@ export default function Settings () {
theme: newTheme
}
})
writeNormalConfig({
await writeNormalConfig({
...normalConfig,
settings: {
...normalConfig.settings,
theme: newTheme
}
})
break
}
}}
>
<option value={0}>Dark (default)</option>