mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2026-04-23 15:02:34 +01:00
Fix health metrics race condition and improve expected-failure handling (#2387)
* Fix health monitoring * fix compile error
This commit is contained in:
@@ -7,14 +7,18 @@ import { ApplicationMetricPhase, CommonMetricPhase } from "./ScenarioConfig";
|
||||
* Hook to automatically complete the Interactive phase when the component becomes interactive.
|
||||
* Uses requestAnimationFrame to complete after the browser has painted.
|
||||
*/
|
||||
export function useInteractive(scenario: MetricScenario) {
|
||||
export function useInteractive(scenario: MetricScenario, enabled = true) {
|
||||
const { completePhase } = useMetricScenario();
|
||||
|
||||
React.useEffect(() => {
|
||||
requestAnimationFrame(() => {
|
||||
if (!enabled) {
|
||||
return undefined;
|
||||
}
|
||||
const id = requestAnimationFrame(() => {
|
||||
completePhase(scenario, CommonMetricPhase.Interactive);
|
||||
});
|
||||
}, [scenario, completePhase]);
|
||||
return () => cancelAnimationFrame(id);
|
||||
}, [scenario, completePhase, enabled]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user