diff --git a/app/src/lib/get-title-bar-config.ts b/app/src/lib/get-title-bar-config.ts index 67472271035..d9e7e7344dc 100644 --- a/app/src/lib/get-title-bar-config.ts +++ b/app/src/lib/get-title-bar-config.ts @@ -20,22 +20,24 @@ export function readTitleBarConfigFileSync(): TitleBarConfig { const titleBarConfigPath = getTitleBarConfigPath() if (existsSync(titleBarConfigPath)) { - const titleBarConfig = JSON.parse( - readFileSync(getTitleBarConfigPath(), 'utf8') + const storedTitleBarConfig = JSON.parse( + readFileSync(titleBarConfigPath, 'utf8') ) - // Return if we found valid values if ( - titleBarConfig.titleBarStyle === 'native' || - titleBarConfig.titleBarStyle === 'custom' + storedTitleBarConfig.titleBarStyle === 'native' || + storedTitleBarConfig.titleBarStyle === 'custom' ) { - cachedTitleBarConfig = titleBarConfig - return titleBarConfig + cachedTitleBarConfig = storedTitleBarConfig } } - // Return the default value if the config file is not found, or if it contains an invalid value. - return { titleBarStyle: 'native' } + // Cache the default value if the config file is not found, or if it contains an invalid value. + if (cachedTitleBarConfig === null) { + cachedTitleBarConfig = { titleBarStyle: 'native' } + } + + return cachedTitleBarConfig } export function saveTitleBarConfigFile(config: TitleBarConfig) {