diff --git a/src/devtools/store.js b/src/devtools/store.js index c1fe80ebbe..ba731a0fd1 100644 --- a/src/devtools/store.js +++ b/src/devtools/store.js @@ -275,16 +275,24 @@ export default class Store extends EventEmitter { } startProfiling(): void { + this._bridge.send('startProfiling'); + // Invalidate suspense cache if profiling data is being (re-)recorded. + // Note that we clear now because any existing data is "stale". this._profilingCache.invalidate(); - this._bridge.send('startProfiling'); this._isProfiling = false; this.emit('isProfiling'); } stopProfiling(): void { this._bridge.send('stopProfiling'); + + // Invalidate suspense cache if profiling data is being (re-)recorded. + // Note that we clear again, in case any views read from the cache while profiling. + // (That would have resolved a now-stale value without any profiling data.) + this._profilingCache.invalidate(); + this._isProfiling = false; this.emit('isProfiling'); } diff --git a/src/devtools/views/Profiler/FilterModal.js b/src/devtools/views/Profiler/FilterModal.js index 8e91ef0a0d..085fee0a7f 100644 --- a/src/devtools/views/Profiler/FilterModal.js +++ b/src/devtools/views/Profiler/FilterModal.js @@ -1,8 +1,7 @@ // @flow -import React, { useCallback, useContext, useEffect, useRef } from 'react'; -import { useModalDismissSignal } from '../hooks'; -import { ProfilerContext } from './ProfilerContext'; +import React, { useCallback, useEffect, useRef } from 'react'; +import { useLocalStorage, useModalDismissSignal } from '../hooks'; import styles from './FilterModal.css'; @@ -11,12 +10,14 @@ type Props = {| |}; export default function FilterModal({ dismissModal }: Props) { - const { - isMinCommitDurationEnabled, - minCommitDuration, - setMinCommitDuration, - setIsMinCommitDurationEnabled, - } = useContext(ProfilerContext); + const [ + isCommitFilterEnabled, + setIsCommitFilterEnabled, + ] = useLocalStorage('isCommitFilterEnabled', false); + const [minCommitDuration, setMinCommitDuration] = useLocalStorage( + 'minCommitDuration', + 0 + ); const handleNumberChange = useCallback( ({ currentTarget }) => { @@ -30,14 +31,14 @@ export default function FilterModal({ dismissModal }: Props) { const handleEnabledChange = useCallback( ({ currentTarget }) => { - setIsMinCommitDurationEnabled(currentTarget.checked); + setIsCommitFilterEnabled(currentTarget.checked); if (currentTarget.checked) { if (inputRef.current !== null) { inputRef.current.focus(); } } }, - [setIsMinCommitDurationEnabled] + [setIsCommitFilterEnabled] ); const inputRef = useRef(null); @@ -56,7 +57,7 @@ export default function FilterModal({ dismissModal }: Props) {