Skip to content

Commit

Permalink
client: Restore spinner even when the event has been cancelled
Browse files Browse the repository at this point in the history
The aborting short circuit has been introduced in 28d27f3

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);}
  • Loading branch information
jtojnar committed Jul 30, 2023
1 parent 8c5a715 commit 5dd1263
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions client/js/templates/EntriesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 5dd1263

Please # to comment.