From f6fb429772c02da976f4173907fdaa9ee97a7c99 Mon Sep 17 00:00:00 2001
From: Terry Truong <terry06890@gmail.com>
Date: Mon, 23 Jan 2023 11:37:08 +1100
Subject: Fix some timelines not updating on category change with multiple
 timelines

---
 src/App.vue | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

(limited to 'src/App.vue')

diff --git a/src/App.vue b/src/App.vue
index 96baefd..4a8c3d9 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -82,7 +82,7 @@ import SettingsIcon from './components/icon/SettingsIcon.vue';
 import PlusIcon from './components/icon/PlusIcon.vue';
 import SearchIcon from './components/icon/SearchIcon.vue';
 
-import {makeThrottled, makeThrottledSpaced} from './util';
+import {makeThrottledSpaced} from './util';
 import {
 	HistDate, HistEvent, EventInfo, cmpHistEvent,
 	queryServer, EventResponseJson, jsonToHistEvent, EventInfoJson, jsonToEventInfo,
@@ -359,7 +359,19 @@ async function handleOnEventDisplay(
 	}
 }
 
-const onEventDisplay = makeThrottled(handleOnEventDisplay, 200);
+const timelineTimeouts: Map<number, number> = new Map();
+	// Maps timeline IDs to setTimeout() timeouts (used to throttle handleEventDisplay() per-timeline)
+
+function onEventDisplay(
+		timelineId: number, eventIds: number[], firstDate: HistDate, lastDate: HistDate, scaleIdx: number){
+	if (timelineTimeouts.has(timelineId)){
+		clearTimeout(timelineTimeouts.get(timelineId));
+	}
+	timelineTimeouts.set(timelineId, window.setTimeout(async () => {
+		timelineTimeouts.delete(timelineId);
+		handleOnEventDisplay(timelineId, eventIds, firstDate, lastDate, scaleIdx);
+	}, 200));
+}
 
 // ========== For info modal ==========
 
-- 
cgit v1.2.3

