From 9267a19c89a39e53ae065e80afaf504a41915e2e Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Tue, 4 Jan 2022 04:16:40 -0800 Subject: [PATCH] Fix settings not being saved before restart Summary: 2022 New years intention: don't fix problems with arbitrarily timeouts In production builds, settings weren't saved if apply + restart was used (apply and manual restart did work). I suspect a bug in redux-persist, since we do await a flush, but anyway a little delay seems to fix it consistently. Changelog: Fixed an issue where changing settings wasn't persisted when using "Apply + Restart P.S. I won't accept any insinuations that this was my new years intention of 2015, 2017, 2018, 2020 and 2021 as well. Reviewed By: cekkaewnumchai Differential Revision: D33377718 fbshipit-source-id: 3a9ec58b4f8208603d786342ddaf6bf02b3887c7 --- desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx b/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx index 1fe58e948..75877ffea 100644 --- a/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx +++ b/desktop/flipper-ui-core/src/chrome/SettingsSheet.tsx @@ -27,6 +27,7 @@ import { Platform, reportUsage, Settings, + sleep, } from 'flipper-common'; import {Modal, message, Button} from 'antd'; import {Layout, withTrackingScope, _NuxManagerContext} from 'flipper-plugin'; @@ -73,9 +74,9 @@ class SettingsSheet extends Component { this.props.updateSettings(this.state.updatedSettings); this.props.updateLauncherSettings(this.state.updatedLauncherSettings); this.props.onHide(); - return flush().then(() => { - getRenderHostInstance().restartFlipper(true); - }); + await flush(); + await sleep(1000); + getRenderHostInstance().restartFlipper(true); }; applyChangesWithoutRestart = async () => {