From f0023ea79d2f193a109ca71cc7b8469cb1c4986b Mon Sep 17 00:00:00 2001 From: Lorenzo Blasa Date: Fri, 27 Oct 2023 03:12:03 -0700 Subject: [PATCH] If there's an existing problem, show regardless Summary: Setup Doctor can be used to discover installation issues. I've seen numerous times when there's a setup issue but users didn't check / bother with using the tool. Instead, if there's an issue, show the screen regardless. Reviewed By: mweststrate Differential Revision: D50642080 fbshipit-source-id: 10eb7a758a61765a5b06d398f5041897fff6280e --- .../src/sandy-chrome/Navbar.tsx | 29 +++++++++++++++++-- .../src/sandy-chrome/SetupDoctorScreen.tsx | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx b/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx index 8e4023c1c..014f9a941 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/Navbar.tsx @@ -38,7 +38,10 @@ import { } from '../reducers/application'; import PluginManager from '../chrome/plugin-manager/PluginManager'; import {showEmulatorLauncher} from './appinspect/LaunchEmulator'; -import SetupDoctorScreen, {checkHasNewProblem} from './SetupDoctorScreen'; +import SetupDoctorScreen, { + checkHasNewProblem, + checkHasProblem, +} from './SetupDoctorScreen'; import {isProduction} from 'flipper-common'; import FpsGraph from '../chrome/FpsGraph'; import NetworkGraph from '../chrome/NetworkGraph'; @@ -456,12 +459,32 @@ function TroubleshootMenu() { ), [store, setStatus], ); - const [isDoctorVisible, setIsDoctorVisible] = useState(false); + + const flipperErrorLogCount = useValue(errorCounterAtom); + + /** + * About Doctor. Get the healthcheck report. + * + * checkHasProblem: check if there are problems in the healthcheck report. + * checkHasNewProblem: check if there are new problems in the healthcheck + * report since the last time it was checked or acknowledged, hence the new keyword. + * + * The first time Flipper is opened, show doctor if there's any problems. + * After this, use hasNewProblems as a means to show Doctor if needed. + */ const result = useStore( (state) => state.healthchecks.healthcheckReport.result, ); + const hasProblem = useMemo(() => checkHasProblem(result), [result]); const hasNewProblem = useMemo(() => checkHasNewProblem(result), [result]); - const flipperErrorLogCount = useValue(errorCounterAtom); + + const [isDoctorVisible, setIsDoctorVisible] = useState(hasProblem); + + useEffect(() => { + if (hasNewProblem) { + setIsDoctorVisible(true); + } + }, [hasNewProblem]); const count = flipperErrorLogCount || hasNewProblem || 0; diff --git a/desktop/flipper-ui-core/src/sandy-chrome/SetupDoctorScreen.tsx b/desktop/flipper-ui-core/src/sandy-chrome/SetupDoctorScreen.tsx index ba9a3ee9a..552a7329e 100644 --- a/desktop/flipper-ui-core/src/sandy-chrome/SetupDoctorScreen.tsx +++ b/desktop/flipper-ui-core/src/sandy-chrome/SetupDoctorScreen.tsx @@ -71,7 +71,7 @@ const statusTypeAndMessage: { }, }; -function checkHasProblem(result: FlipperDoctor.HealthcheckResult) { +export function checkHasProblem(result: FlipperDoctor.HealthcheckResult) { return result.status === 'FAILED' || result.status === 'WARNING'; }