From 353556bed4e097e118acb217f780bb3bbe6d7b02 Mon Sep 17 00:00:00 2001 From: Tim Down <158919+timdown@users.noreply.github.com> Date: Tue, 2 May 2023 15:17:00 +0100 Subject: [PATCH] Merge pull request #12870 from overleaf/td-history-prevent-diff-render-on-label-change History migration: prevent unnecessary render when adding or deleting a label GitOrigin-RevId: acabd581403f17f863e3bd0c06d1fbd77fe22228 --- .../js/features/history/context/history-context.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/services/web/frontend/js/features/history/context/history-context.tsx b/services/web/frontend/js/features/history/context/history-context.tsx index 5e54517e59..6460603711 100644 --- a/services/web/frontend/js/features/history/context/history-context.tsx +++ b/services/web/frontend/js/features/history/context/history-context.tsx @@ -187,12 +187,13 @@ function useHistory() { } }, [view, fetchNextBatchOfUpdates]) - const { updateRange, comparing } = selection + const { updateRange, comparing, files } = selection const { updates } = updatesInfo + const filesEmpty = files.length === 0 // Load files when the update selection changes useEffect(() => { - if (!updateRange) { + if (!updateRange || !filesEmpty) { return } const { fromV, toV } = updateRange @@ -222,7 +223,7 @@ function useHistory() { .catch(error => { setError(error) }) - }, [updateRange, projectId, updates, comparing, setError]) + }, [updateRange, projectId, updates, comparing, setError, filesEmpty]) useEffect(() => { // Set update range if there isn't one and updates have loaded