From cfbdc4dbb57a71e0a33e38cce974fa338ee49efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathis=20Dr=C3=B6ge?= Date: Sun, 21 Jul 2024 18:00:13 +0200 Subject: [PATCH] [Fix] Sideload: Don't update game settings if we're in editMode (#3848) Don't update game settings if we're in editMode EditMode hides the Wine prefix/version / CrossOver bottle selector and also doesn't set it, so clicking "Finish" resets them to their default values --- .../InstallModal/SideloadDialog/index.tsx | 44 +++++++------------ 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx b/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx index 8824b4035d..ffddd7f250 100644 --- a/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx +++ b/src/frontend/screens/Library/components/InstallModal/SideloadDialog/index.tsx @@ -114,25 +114,14 @@ export default function SideloadDialog({ } }, []) + // Suggest default Wine prefix if we're adding a new app useEffect(() => { - const setWine = async () => { - if (editMode && appName) { - const appSettings = await window.api.getGameSettings( - appName, - 'sideload' - ) - if (appSettings?.winePrefix) { - setWinePrefix(appSettings.winePrefix) - } - return - } else { - const { defaultWinePrefix } = await window.api.requestAppSettings() - const sugestedWinePrefix = `${defaultWinePrefix}/${title}` - setWinePrefix(sugestedWinePrefix) - } - } - setWine() - }, [title]) + if (editMode) return + window.api.requestAppSettings().then(({ defaultWinePrefix }) => { + const suggestedWinePrefix = `${defaultWinePrefix}/${title}` + setWinePrefix(suggestedWinePrefix) + }) + }, [title, editMode]) async function searchImage() { setSearching(true) @@ -181,15 +170,16 @@ export default function SideloadDialog({ if (!gameSettings) { return } - await writeConfig({ - appName: app_name, - config: { - ...gameSettings, - winePrefix, - wineVersion, - wineCrossoverBottle: crossoverBottle - } - }) + if (!editMode) + window.api.writeConfig({ + appName: app_name, + config: { + ...gameSettings, + winePrefix, + wineVersion, + wineCrossoverBottle: crossoverBottle + } + }) await refreshLibrary({ library: 'sideload',