Fix some issues
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
import { useEffect, useRef, useState } from 'react'
|
import { useCallback, useEffect, useRef, useState } from 'react'
|
||||||
import Sidebar from './componets/Sidebar'
|
import Sidebar from './componets/Sidebar'
|
||||||
import './Globals.css'
|
import './Globals.css'
|
||||||
import { DownloadProgress } from './types/DownloadProgress'
|
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
|
if (!id) return undefined
|
||||||
return serverVersionList?.versions.find(v => v.id === id)
|
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
|
if (!game) return undefined
|
||||||
return serverVersionList?.games.find(g => g.id === game)
|
return serverVersionList?.games.find(g => g.id === game)
|
||||||
}
|
},
|
||||||
|
[serverVersionList]
|
||||||
|
)
|
||||||
|
|
||||||
function getListOfGames (): Game[] {
|
function getListOfGames (): Game[] {
|
||||||
if (!downloadedVersionsConfig?.list) return []
|
if (!downloadedVersionsConfig?.list) return []
|
||||||
@@ -292,10 +298,8 @@ export default function RootLayout ({
|
|||||||
return () => document.removeEventListener('contextmenu', handler)
|
return () => document.removeEventListener('contextmenu', handler)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
async function downloadVersions (
|
const downloadVersions = useCallback(
|
||||||
list: string[],
|
async (list: string[], currentConfig: VersionsConfig): Promise<void> => {
|
||||||
currentConfig: VersionsConfig
|
|
||||||
): Promise<void> {
|
|
||||||
if (list.length === 0) return
|
if (list.length === 0) return
|
||||||
setSelectedVersionList([])
|
setSelectedVersionList([])
|
||||||
|
|
||||||
@@ -374,7 +378,9 @@ export default function RootLayout ({
|
|||||||
|
|
||||||
setFadeOut(true)
|
setFadeOut(true)
|
||||||
setTimeout(() => setShowPopup(false), 200)
|
setTimeout(() => setShowPopup(false), 200)
|
||||||
}
|
},
|
||||||
|
[getGameInfo, getVersionInfo, normalConfig]
|
||||||
|
)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (revisionCheck.current) return
|
if (revisionCheck.current) return
|
||||||
@@ -404,7 +410,7 @@ export default function RootLayout ({
|
|||||||
|
|
||||||
await downloadVersions(versionsToSelect, newConfig)
|
await downloadVersions(versionsToSelect, newConfig)
|
||||||
})()
|
})()
|
||||||
}, [serverVersionList, downloadedVersionsConfig])
|
}, [serverVersionList, downloadedVersionsConfig, downloadVersions])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default function Settings () {
|
|||||||
label='Allow sending notifications'
|
label='Allow sending notifications'
|
||||||
value={allowNotifications}
|
value={allowNotifications}
|
||||||
onChange={async () => {
|
onChange={async () => {
|
||||||
while (normalConfig != null) {
|
if (!normalConfig) return
|
||||||
setAllowNotifications(!allowNotifications)
|
setAllowNotifications(!allowNotifications)
|
||||||
setNormalConfig({
|
setNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
@@ -59,15 +59,13 @@ export default function Settings () {
|
|||||||
allowNotifications: !allowNotifications
|
allowNotifications: !allowNotifications
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
writeNormalConfig({
|
await writeNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
settings: {
|
settings: {
|
||||||
...normalConfig.settings,
|
...normalConfig.settings,
|
||||||
allowNotifications: !allowNotifications
|
allowNotifications: !allowNotifications
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
break
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
title='This setting does as you expect, allow the launcher to send notifications for when stuff like downloading is done.'
|
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'
|
label='Always show games in sidebar'
|
||||||
value={alwaysShowGamesInSidebar}
|
value={alwaysShowGamesInSidebar}
|
||||||
onChange={async () => {
|
onChange={async () => {
|
||||||
while (normalConfig != null) {
|
if (!normalConfig) return
|
||||||
setAlwaysShowGamesInSidebar(!alwaysShowGamesInSidebar)
|
setAlwaysShowGamesInSidebar(!alwaysShowGamesInSidebar)
|
||||||
setNormalConfig({
|
setNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
@@ -84,15 +82,13 @@ export default function Settings () {
|
|||||||
alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar
|
alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
writeNormalConfig({
|
await writeNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
settings: {
|
settings: {
|
||||||
...normalConfig.settings,
|
...normalConfig.settings,
|
||||||
alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar
|
alwaysShowGamesInSidebar: !alwaysShowGamesInSidebar
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
break
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
title="This setting will make it so when you are on a page like this, the games won't disappear."
|
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'
|
label='Show Installs/Launch/Manage Buttons'
|
||||||
value={useLegacyInteractButtons}
|
value={useLegacyInteractButtons}
|
||||||
onChange={async () => {
|
onChange={async () => {
|
||||||
while (normalConfig != null) {
|
if (!normalConfig) return
|
||||||
setUseLegacyInteractButtons(!useLegacyInteractButtons)
|
setUseLegacyInteractButtons(!useLegacyInteractButtons)
|
||||||
setNormalConfig({
|
setNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
@@ -109,15 +105,13 @@ export default function Settings () {
|
|||||||
useLegacyInteractButtons: !useLegacyInteractButtons
|
useLegacyInteractButtons: !useLegacyInteractButtons
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
writeNormalConfig({
|
await writeNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
settings: {
|
settings: {
|
||||||
...normalConfig.settings,
|
...normalConfig.settings,
|
||||||
useLegacyInteractButtons: !useLegacyInteractButtons
|
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.'
|
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'
|
label='Use wine when needed to launch games'
|
||||||
value={useWineOnUnixWhenNeeded}
|
value={useWineOnUnixWhenNeeded}
|
||||||
onChange={async () => {
|
onChange={async () => {
|
||||||
while (normalConfig != null) {
|
if (!normalConfig) return
|
||||||
setUseWineOnUnixWhenNeeded(!useWineOnUnixWhenNeeded)
|
setUseWineOnUnixWhenNeeded(!useWineOnUnixWhenNeeded)
|
||||||
normalConfig.settings.useWineOnUnixWhenNeeded =
|
setNormalConfig({
|
||||||
!useWineOnUnixWhenNeeded
|
...normalConfig,
|
||||||
await writeNormalConfig(normalConfig)
|
settings: {
|
||||||
break
|
...normalConfig.settings,
|
||||||
|
useWineOnUnixWhenNeeded: !useWineOnUnixWhenNeeded
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
await writeNormalConfig({
|
||||||
|
...normalConfig,
|
||||||
|
settings: {
|
||||||
|
...normalConfig.settings,
|
||||||
|
useWineOnUnixWhenNeeded: !useWineOnUnixWhenNeeded
|
||||||
|
}
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
className={platform() == 'linux' ? '' : 'hidden'}
|
className={platform() == 'linux' ? '' : 'hidden'}
|
||||||
/>
|
/>
|
||||||
@@ -142,12 +145,22 @@ export default function Settings () {
|
|||||||
type='text'
|
type='text'
|
||||||
value={wineOnUnixCommand}
|
value={wineOnUnixCommand}
|
||||||
onChange={async e => {
|
onChange={async e => {
|
||||||
while (normalConfig != null) {
|
if (!normalConfig) return
|
||||||
setWineOnUnixCommand(e.target.value)
|
setWineOnUnixCommand(e.target.value)
|
||||||
normalConfig.settings.wineOnUnixCommand = e.target.value
|
setNormalConfig({
|
||||||
await writeNormalConfig(normalConfig)
|
...normalConfig,
|
||||||
break
|
settings: {
|
||||||
|
...normalConfig.settings,
|
||||||
|
wineOnUnixCommand: e.target.value
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
await writeNormalConfig({
|
||||||
|
...normalConfig,
|
||||||
|
settings: {
|
||||||
|
...normalConfig.settings,
|
||||||
|
wineOnUnixCommand: e.target.value
|
||||||
|
}
|
||||||
|
})
|
||||||
}}
|
}}
|
||||||
className={`input-field my-1 ${
|
className={`input-field my-1 ${
|
||||||
platform() == 'linux' && useWineOnUnixWhenNeeded ? '' : 'hidden'
|
platform() == 'linux' && useWineOnUnixWhenNeeded ? '' : 'hidden'
|
||||||
@@ -159,8 +172,8 @@ export default function Settings () {
|
|||||||
className='ml-2 bg-(--col2) border border-(--col4) rounded-md'
|
className='ml-2 bg-(--col2) border border-(--col4) rounded-md'
|
||||||
value={theme}
|
value={theme}
|
||||||
onChange={async e => {
|
onChange={async e => {
|
||||||
|
if (!normalConfig) return
|
||||||
const newTheme = parseInt(e.target.value)
|
const newTheme = parseInt(e.target.value)
|
||||||
while (normalConfig != null) {
|
|
||||||
setTheme(newTheme)
|
setTheme(newTheme)
|
||||||
setNormalConfig({
|
setNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
@@ -169,15 +182,13 @@ export default function Settings () {
|
|||||||
theme: newTheme
|
theme: newTheme
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
writeNormalConfig({
|
await writeNormalConfig({
|
||||||
...normalConfig,
|
...normalConfig,
|
||||||
settings: {
|
settings: {
|
||||||
...normalConfig.settings,
|
...normalConfig.settings,
|
||||||
theme: newTheme
|
theme: newTheme
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
break
|
|
||||||
}
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<option value={0}>Dark (default)</option>
|
<option value={0}>Dark (default)</option>
|
||||||
|
|||||||
Reference in New Issue
Block a user