Add relaunch, reset, delete download cache, delete invalid games buttons to settings page

This commit is contained in:
Lncvrt committed 2026-05-08 17:11:31 -07:00
1 parent 3f27a330b6
commit 43678cc64d
2 files changed
+148 -2

No files matched your search

+1
View File
@@ -20,6 +20,7 @@
"core:window:allow-request-user-attention",
"core:webview:allow-create-webview-window",
"fs:default",
"fs:allow-remove",
"dialog:default",
"dialog:allow-open",
"notification:default",
+147 -2
View File
@@ -4,15 +4,20 @@ import { Setting } from '@/components/Setting'
import { useGlobal } from '@/providers/GlobalProvider'
import { copyToClipboard } from '@/lib/clipboard'
import { platform } from '@tauri-apps/plugin-os'
import { open } from '@tauri-apps/plugin-dialog'
import { message, open } from '@tauri-apps/plugin-dialog'
import { invoke } from '@tauri-apps/api/core'
import Dropdown from '@/components/Dropdown'
import { WebviewWindow } from '@tauri-apps/api/webviewWindow'
import { relaunch } from '@tauri-apps/plugin-process'
import { BaseDirectory, exists, readDir, remove } from '@tauri-apps/plugin-fs'
export default function Settings () {
const {
settings,
versions,
account,
version,
versionsList,
notificationsAllowed,
sidebarAlwaysShowGames,
linuxUseWine,
@@ -26,7 +31,8 @@ export default function Settings () {
return (
<>
<p className='text-3xl ml-4 mt-4'>Settings</p>
<div className='ml-4 mt-4 bg-(--col1) border border-(--col3) rounded-lg p-4 w-fit h-fit'>
<div className='flex flex-row p-4 gap-4'>
<div className='bg-(--col1) border border-(--col3) rounded-lg p-4 w-fit h-fit'>
<Setting
label='Allow sending notifications'
value={notificationsAllowed}
@@ -143,6 +149,145 @@ export default function Settings () {
/>
</div>
</div>
<div className='bg-(--col1) border border-(--col3) rounded-lg p-4 w-fit h-fit flex flex-col gap-2'>
<button
className='button btntheme1'
title="Restarts the launcher. I don't think I needed to add this description."
onClick={async () => await relaunch()}
>
Restart launcher
</button>
<button
className='button btntheme1'
title='Completely reset the launcher, delete games, logout of account & reset settings.'
onClick={async () => {
if (
await exists(
(customDataLocation ? customDataLocation + '/' : null) +
'game',
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData
}
)
)
await remove(
(customDataLocation ? customDataLocation + '/' : null) +
'game',
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData,
recursive: true
}
)
if (
await exists(
(customDataLocation ? customDataLocation + '/' : null) +
'downloads',
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData
}
)
)
await remove(
(customDataLocation ? customDataLocation + '/' : null) +
'downloads',
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData,
recursive: true
}
)
await settings?.clear()
await versions?.clear()
await account?.clear()
await relaunch()
}}
>
Reset launcher
</button>
<button
className='button btntheme1'
title='If you pause or cancel a download, it will be removed here.'
onClick={async () => {
if (
await exists(
(customDataLocation ? customDataLocation + '/' : null) +
'downloads',
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData
}
)
)
await remove(
(customDataLocation ? customDataLocation + '/' : null) +
'downloads',
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData,
recursive: true
}
)
}}
>
Delete download cache
</button>
<button
className='button btntheme1'
title='If you had a game that was downloaded before it was taken down after you downloaded it, it will get removed here.'
onClick={async () => {
const items = await readDir(
(customDataLocation ? customDataLocation + '/' : null) + 'game',
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData
}
)
const removed: string[] = []
for (const item of items) {
if (item.isFile || item.isSymlink) continue
if (
!Object.entries(versionsList).find(v => v[0] == item.name)
) {
removed.push(item.name)
await remove(
(customDataLocation ? customDataLocation + '/' : null) +
'game/' +
item.name,
{
baseDir: customDataLocation
? undefined
: BaseDirectory.AppLocalData,
recursive: true
}
)
}
}
message(
'Removed the following game items: ' +
(removed.length == 0 ? '(none)' : removed.join(', ')),
{ title: 'Sucessfully cleaned games folder', kind: 'info' }
)
}}
>
Delete invalid/unavailable games
</button>
<p className='text-center'>Hover buttons for descriptions</p>
</div>
</div>
<p
className='fixed bottom-1.5 right-1.5 rounded-md cursor-pointer px-1 border z-100 transition-colors btntheme1'
onClick={async () =>