From b9b09296683a40829661a25b6d5e65d639d57dcc Mon Sep 17 00:00:00 2001 From: fnrir Date: Tue, 27 Jun 2023 10:50:55 +0200 Subject: [PATCH] Fix trying to open nonexistant config If you try to open settings, or change the "Toggle Encryption" toggle, while GC's server config does not exist it no longer throws an error message. --- src/ui/components/menu/Options.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/ui/components/menu/Options.tsx b/src/ui/components/menu/Options.tsx index 7b93a86..9c584dd 100644 --- a/src/ui/components/menu/Options.tsx +++ b/src/ui/components/menu/Options.tsx @@ -99,10 +99,13 @@ export default class Options extends React.Component { const languages = await getLanguages() const platform: string = await invoke('get_platform') - // Remove jar from path - const path = config.grasscutter_path.replace(/\\/g, '/') - const folderPath = path.substring(0, path.lastIndexOf('/')) - const encEnabled = await server.encryptionEnabled(folderPath + '/config.json') + let encEnabled + if (config.grasscutter_path) { + // Remove jar from path + const path = config.grasscutter_path.replace(/\\/g, '/') + const folderPath = path.substring(0, path.lastIndexOf('/')) + encEnabled = await server.encryptionEnabled(folderPath + '/config.json') + } console.log(platform)