From b64a76e6bdf8db0c9fd26ae038cbf308a4301e57 Mon Sep 17 00:00:00 2001 From: Brian Vaughn Date: Mon, 18 Mar 2019 13:53:10 -0700 Subject: [PATCH] Reset selected commit and fiber between profiling sessions --- src/devtools/views/Profiler/ProfilerContext.js | 9 +++++++++ src/devtools/views/Profiler/SnapshotSelector.js | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/devtools/views/Profiler/ProfilerContext.js b/src/devtools/views/Profiler/ProfilerContext.js index 490db544c8..d6d0a96a4f 100644 --- a/src/devtools/views/Profiler/ProfilerContext.js +++ b/src/devtools/views/Profiler/ProfilerContext.js @@ -124,6 +124,15 @@ function ProfilerContextController({ children }: Props) { const [selectedFiberID, selectFiber] = useState(null); + if (isProfiling) { + if (selectedFiberID !== null) { + selectFiber(null); + } + if (selectedCommitIndex !== null) { + setSelectedCommitIndex(null); + } + } + const value = useMemo( () => ({ hasProfilingData, diff --git a/src/devtools/views/Profiler/SnapshotSelector.js b/src/devtools/views/Profiler/SnapshotSelector.js index fa6469b54e..ff4abdf4ae 100644 --- a/src/devtools/views/Profiler/SnapshotSelector.js +++ b/src/devtools/views/Profiler/SnapshotSelector.js @@ -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);