aboutsummaryrefslogtreecommitdiff
path: root/src/App.vue
diff options
context:
space:
mode:
authorTerry Truong <terry06890@gmail.com>2022-10-18 20:03:51 +1100
committerTerry Truong <terry06890@gmail.com>2022-10-18 20:03:51 +1100
commitdfe71f33e24b9ed5b8ecc674423216a0f5487283 (patch)
tree71dd4709e01c832ce67b5ec7a6ce0391186819e3 /src/App.vue
parentc7e965fc3dc6ffe01e6d4823d56f7b604fef6270 (diff)
Serialise event-req handling
Also skip unnecessary render on startup
Diffstat (limited to 'src/App.vue')
-rw-r--r--src/App.vue9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/App.vue b/src/App.vue
index 5bf6458..17760b0 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -39,7 +39,8 @@ import PlusIcon from './components/icon/PlusIcon.vue';
import SettingsIcon from './components/icon/SettingsIcon.vue';
import HelpIcon from './components/icon/HelpIcon.vue';
// Other
-import {HistDate, TimelineState, HistEvent, queryServer, HistEventJson, jsonToHistEvent, cmpHistEvent} from './lib';
+import {HistDate, TimelineState, HistEvent, queryServer, HistEventJson, jsonToHistEvent, cmpHistEvent,
+ timeout} from './lib';
import {useStore} from './store';
import {RBTree, rbtree_shallow_copy} from './rbtree';
@@ -191,7 +192,12 @@ function reduceEvents(){
}
// For getting events from server
const EVENT_REQ_LIMIT = 10;
+let pendingReq = false; // Used to serialise event-req handling
async function onEventReq(startDate: HistDate, endDate: HistDate){
+ while (pendingReq){
+ await timeout(100);
+ }
+ pendingReq = true;
// Exclude exhausted range
if (isExhaustedRange(startDate, endDate)){
return;
@@ -238,6 +244,7 @@ async function onEventReq(startDate: HistDate, endDate: HistDate){
if (eventTree.value.size > EXCESS_EVENTS_THRESHOLD){
reduceEvents();
}
+ pendingReq = false;
}
// For resize handling