From 5dd1263b52991ddc8f5b2ecbd1e801dded535aa9 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 30 Jul 2023 04:59:52 +0200 Subject: [PATCH] client: Restore spinner even when the event has been cancelled The aborting short circuit has been introduced in 28d27f31c7dd0441d6088fbf9d4ed80fa6dbf237 It can happen that the request is cancelled by another request but the second request will use `setLoadingState` instead of `setMoreLoadingState` so `moreLoadingState` will be stuck on `LOADING`. Not sure if it this cannot introduce a race if the same state is used in both requests. Tried testing with {let a = new AbortController(); let f = fetch('wait.php?seconds=3', {signal: a.signal}); f.then(r => console.log(r, a)); setTimeout(() => {a.abort(); f.then((r) => console.log(r, a.signal))}, 100);} --- client/js/templates/EntriesPage.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client/js/templates/EntriesPage.jsx b/client/js/templates/EntriesPage.jsx index 29a1e566aa..d19697565e 100644 --- a/client/js/templates/EntriesPage.jsx +++ b/client/js/templates/EntriesPage.jsx @@ -111,13 +111,13 @@ function reloadList({ setLoadingState(LoadingState.LOADING); return reloader(fetchParams, abortController).then(({ entries, hasMore }) => { + setLoadingState(LoadingState.SUCCESS); + selfoss.entriesPage.setHasMore(hasMore); + if (abortController.signal.aborted) { return; } - setLoadingState(LoadingState.SUCCESS); - selfoss.entriesPage.setHasMore(hasMore); - if (append) { selfoss.entriesPage.appendEntries(entries); } else {