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
This commit is contained in:
Lorenzo Blasa
2023-10-27 03:12:03 -07:00
committed by Facebook GitHub Bot
parent 9aadcefbf9
commit f0023ea79d
2 changed files with 27 additions and 4 deletions

View File

@@ -38,7 +38,10 @@ import {
} from '../reducers/application'; } from '../reducers/application';
import PluginManager from '../chrome/plugin-manager/PluginManager'; import PluginManager from '../chrome/plugin-manager/PluginManager';
import {showEmulatorLauncher} from './appinspect/LaunchEmulator'; import {showEmulatorLauncher} from './appinspect/LaunchEmulator';
import SetupDoctorScreen, {checkHasNewProblem} from './SetupDoctorScreen'; import SetupDoctorScreen, {
checkHasNewProblem,
checkHasProblem,
} from './SetupDoctorScreen';
import {isProduction} from 'flipper-common'; import {isProduction} from 'flipper-common';
import FpsGraph from '../chrome/FpsGraph'; import FpsGraph from '../chrome/FpsGraph';
import NetworkGraph from '../chrome/NetworkGraph'; import NetworkGraph from '../chrome/NetworkGraph';
@@ -456,12 +459,32 @@ function TroubleshootMenu() {
), ),
[store, setStatus], [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( const result = useStore(
(state) => state.healthchecks.healthcheckReport.result, (state) => state.healthchecks.healthcheckReport.result,
); );
const hasProblem = useMemo(() => checkHasProblem(result), [result]);
const hasNewProblem = useMemo(() => checkHasNewProblem(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; const count = flipperErrorLogCount || hasNewProblem || 0;

View File

@@ -71,7 +71,7 @@ const statusTypeAndMessage: {
}, },
}; };
function checkHasProblem(result: FlipperDoctor.HealthcheckResult) { export function checkHasProblem(result: FlipperDoctor.HealthcheckResult) {
return result.status === 'FAILED' || result.status === 'WARNING'; return result.status === 'FAILED' || result.status === 'WARNING';
} }