fix load older events in listView

This commit is contained in:
Tim Gröger 2023-05-03 00:19:09 +02:00
parent b5d43bb1de
commit 6f6fca84ed
1 changed files with 12 additions and 2 deletions

View File

@ -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);
}