From f6fb429772c02da976f4173907fdaa9ee97a7c99 Mon Sep 17 00:00:00 2001 From: Terry Truong 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 ++++++++++++++-- src/components/InfoModal.vue | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src') 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 = 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 ========== diff --git a/src/components/InfoModal.vue b/src/components/InfoModal.vue index 795b21c..237934d 100644 --- a/src/components/InfoModal.vue +++ b/src/components/InfoModal.vue @@ -82,7 +82,7 @@
{{eventInfo.desc}}
(No description found)
-- cgit v1.2.3