From bae2043e06e7e5dcd90014041dc24b05af30f266 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 14 Sep 2021 03:15:55 -0700 Subject: [PATCH] Fix theme updating issue Summary: Follow up on D29436059 (https://github.com/facebook/flipper/commit/014e571f74790617cb91713bf8356651a358f593), another place where the old format was leaked. Fixes https://github.com/facebook/flipper/issues/2842 + some mentions on WP Changelog: Fixed JavaScript exception on main thread occurring after loading Flipper Reviewed By: nikoant Differential Revision: D30928768 fbshipit-source-id: 083731e18230825738466b34368c2b5f730e386c --- desktop/static/main.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/desktop/static/main.ts b/desktop/static/main.ts index 1c4486bd3..7567df88b 100644 --- a/desktop/static/main.ts +++ b/desktop/static/main.ts @@ -34,6 +34,8 @@ import {promisify} from 'util'; const VERSION: string = (global as any).__VERSION__; +const validThemes = ['light', 'dark', 'system']; + // Adds system PATH folders to process.env.PATH for MacOS production bundles. fixPath(); @@ -109,7 +111,7 @@ if (argv['disable-gpu'] || process.env.FLIPPER_DISABLE_GPU === '1') { } process.env.CONFIG = JSON.stringify(config); -nativeTheme.themeSource = ['light', 'dark', 'system'].includes(config.darkMode) +nativeTheme.themeSource = validThemes.includes(config.darkMode) ? config.darkMode : 'light'; @@ -291,7 +293,11 @@ ipcMain.on('getLaunchTime', (event) => { }); ipcMain.on('setTheme', (_e, mode: 'light' | 'dark' | 'system') => { - nativeTheme.themeSource = mode; + if (validThemes.includes(mode)) { + nativeTheme.themeSource = mode; + } else { + console.warn('Received invalid theme: ' + mode); + } }); ipcMain.on(