()
const { updateRange, selectedFile } = selection
useEffect(() => {
- if (!updateRange || !selectedFile?.pathname) {
+ if (!updateRange || !selectedFile?.pathname || loadingFileDiffs) {
return
}
@@ -44,7 +45,7 @@ function DiffView() {
setDiff(diff)
})
.catch(console.error)
- }, [projectId, runAsync, updateRange, selectedFile])
+ }, [projectId, runAsync, updateRange, selectedFile, loadingFileDiffs])
return (
@@ -56,7 +57,7 @@ function DiffView() {
-
+
>
)}
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 6460603711..8406a8d9e6 100644
--- a/services/web/frontend/js/features/history/context/history-context.tsx
+++ b/services/web/frontend/js/features/history/context/history-context.tsx
@@ -133,7 +133,12 @@ function useHistory() {
}
}
- if (updatesInfo.atEnd || loadingState === 'loadingUpdates') return
+ if (
+ updatesInfo.atEnd ||
+ !(loadingState === 'loadingInitial' || loadingState === 'ready')
+ ) {
+ return
+ }
const updatesPromise = limitUpdates(
fetchUpdates(projectId, updatesInfo.nextBeforeTimestamp)
@@ -193,11 +198,13 @@ function useHistory() {
// Load files when the update selection changes
useEffect(() => {
- if (!updateRange || !filesEmpty) {
+ if (!updateRange || loadingState !== 'ready' || !filesEmpty) {
return
}
const { fromV, toV } = updateRange
+ setLoadingState('loadingFileDiffs')
+
diffFiles(projectId, fromV, toV)
.then(({ diff: files }) => {
const selectedFile = autoSelectFile(
@@ -223,7 +230,18 @@ function useHistory() {
.catch(error => {
setError(error)
})
- }, [updateRange, projectId, updates, comparing, setError, filesEmpty])
+ .finally(() => {
+ setLoadingState('ready')
+ })
+ }, [
+ updateRange,
+ projectId,
+ updates,
+ comparing,
+ setError,
+ loadingState,
+ filesEmpty,
+ ])
useEffect(() => {
// Set update range if there isn't one and updates have loaded
diff --git a/services/web/frontend/js/features/history/context/types/history-context-value.ts b/services/web/frontend/js/features/history/context/types/history-context-value.ts
index a61bd56afa..42d219187b 100644
--- a/services/web/frontend/js/features/history/context/types/history-context-value.ts
+++ b/services/web/frontend/js/features/history/context/types/history-context-value.ts
@@ -6,6 +6,7 @@ import { Selection } from '../../services/types/selection'
type LoadingState =
| 'loadingInitial'
| 'loadingUpdates'
+ | 'loadingFileDiffs'
| 'restoringFile'
| 'ready'