Reset selected commit and fiber between profiling sessions

This commit is contained in:
Brian Vaughn
2019-03-18 13:53:10 -07:00
parent 9b6ee0bb22
commit b64a76e6bd
2 changed files with 11 additions and 1 deletions
@@ -124,6 +124,15 @@ function ProfilerContextController({ children }: Props) {
const [selectedFiberID, selectFiber] = useState<number | null>(null);
if (isProfiling) {
if (selectedFiberID !== null) {
selectFiber(null);
}
if (selectedCommitIndex !== null) {
setSelectedCommitIndex(null);
}
}
const value = useMemo(
() => ({
hasProfilingData,
@@ -56,7 +56,8 @@ export default function SnapshotSelector(_: Props) {
}, [filteredCommitIndices, selectedCommitIndex]);
// TODO (profiling) This should be managed by the context controller (reducer).
// TODO (profiling) We should also reset the selected index to 0 between profiling sessions.
// It doesn't currently know about the filtered commits though (since it doesn't suspend).
// Maybe this component should pass filteredCommitIndices up?
if (selectedFilteredCommitIndex === null) {
if (numFilteredCommits > 0) {
setSelectedCommitIndex(0);