Fix spinner appearing every 5 secds
This commit is contained in:
@@ -8,16 +8,18 @@
|
||||
// Subscribe to the store
|
||||
const unsubscribe = pendingRequests.subscribe(count => {
|
||||
if (count > 0) {
|
||||
// Only show the spinner if the request takes longer than 300ms
|
||||
// Only show the spinner if the request takes longer than 1000ms
|
||||
if (!timer) {
|
||||
timer = setTimeout(() => {
|
||||
showSpinner = true;
|
||||
}, 300);
|
||||
}, 1000);
|
||||
}
|
||||
} else {
|
||||
// Instantly hide the spinner when all requests finish
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timer = null;
|
||||
}
|
||||
showSpinner = false;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user