From 6f6fca84ed063d3a6306f4a1a0fd5a802d52ec41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Wed, 3 May 2023 00:19:09 +0200 Subject: [PATCH] fix load older events in listView --- src/components/overview/ListView.vue | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/overview/ListView.vue b/src/components/overview/ListView.vue index a7ba069..e25c978 100644 --- a/src/components/overview/ListView.vue +++ b/src/components/overview/ListView.vue @@ -99,7 +99,12 @@ export default defineComponent({ const start = new Date(); if (index < 0) { const { result } = await store.getEvents({ to: start, limit: 5, descending: true }); - events.value.unshift(...result); + //events.value.unshift(...result); + for (const event of result) { + const idx = events.value.findIndex((e) => e.id === event.id); + if (idx === -1) events.value.unshift(event); + else events.value[idx] = event; + } if (done) done(false); } else { const len = events.value.length; @@ -108,7 +113,12 @@ export default defineComponent({ offset: (index - 1) * 10, limit: 10, }); - if (len == events.value.push(...result)) { + for (const event of result) { + const idx = events.value.findIndex((e) => e.id === event.id); + if (idx === -1) events.value.unshift(event); + else events.value[idx] = event; + } + if (len == events.value.length) { if (done) return done(true); } else if (done) done(false); }