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'; }