From 1e34561ae39fdd6e59d0c6a76a045ab54de2ec79 Mon Sep 17 00:00:00 2001 From: Chaiwat Ekkaewnumchai Date: Sun, 20 Dec 2020 21:43:52 -0800 Subject: [PATCH] Force Restart Flipper When Applying Sandy Summary: Discovered while testing D25584424, Sandy can't be applied and unapplied by regularly changing the setting. This diff forces restart Flipper to correctly apply or unapply Sandy. This diff adds forced restart updated setting to check if restart is needed or not. Then, it disables regular `Apply` when restart is needed Reviewed By: nikoant Differential Revision: D25632887 fbshipit-source-id: 88b31fd740d4a639e20fe45a82e2615b53cad5c3 --- desktop/app/src/chrome/SettingsSheet.tsx | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/desktop/app/src/chrome/SettingsSheet.tsx b/desktop/app/src/chrome/SettingsSheet.tsx index af083cb0b..d6f93de00 100644 --- a/desktop/app/src/chrome/SettingsSheet.tsx +++ b/desktop/app/src/chrome/SettingsSheet.tsx @@ -22,7 +22,7 @@ import {flush} from '../utils/persistor'; import ToggledSection from './settings/ToggledSection'; import {FilePathConfigField, ConfigText} from './settings/configFields'; import KeyboardShortcutInput from './settings/KeyboardShortcutInput'; -import {isEqual} from 'lodash'; +import {isEqual, isMatch, isEmpty} from 'lodash'; import restartFlipper from '../utils/restartFlipper'; import LauncherSettingsPanel from '../fb-stubs/LauncherSettingsPanel'; import SandySettingsPanel from '../fb-stubs/SandySettingsPanel'; @@ -64,6 +64,8 @@ type DispatchFromProps = { type State = { updatedSettings: Settings; updatedLauncherSettings: LauncherSettings; + forcedRestartSettings: Partial; + forcedRestartLauncherSettings: Partial; }; type Props = OwnProps & StateFromProps & DispatchFromProps; @@ -71,6 +73,8 @@ class SettingsSheet extends Component { state: State = { updatedSettings: {...this.props.settings}, updatedLauncherSettings: {...this.props.launcherSettings}, + forcedRestartSettings: {}, + forcedRestartLauncherSettings: {}, }; componentDidMount() { @@ -147,6 +151,15 @@ class SettingsSheet extends Component { isEqual(this.props.settings, this.state.updatedSettings) && isEqual(this.props.launcherSettings, this.state.updatedLauncherSettings); + const forcedRestart = + (!isEmpty(this.state.forcedRestartSettings) && + !isMatch(this.props.settings, this.state.forcedRestartSettings)) || + (!isEmpty(this.state.forcedRestartLauncherSettings) && + !isMatch( + this.props.launcherSettings, + this.state.forcedRestartLauncherSettings, + )); + const contents = ( { ...this.state.updatedLauncherSettings, releaseChannel: v, }, + forcedRestartLauncherSettings: { + ...this.state.forcedRestartLauncherSettings, + releaseChannel: v, + }, }); }} /> @@ -256,6 +273,10 @@ class SettingsSheet extends Component { ...this.state.updatedSettings, disableSandy: v, }, + forcedRestartSettings: { + ...this.state.forcedRestartSettings, + disableSandy: v, + }, }); }} /> @@ -346,7 +367,7 @@ class SettingsSheet extends Component { Cancel