fix load older events in listView
This commit is contained in:
parent
b5d43bb1de
commit
6f6fca84ed
|
@ -99,7 +99,12 @@ export default defineComponent({
|
||||||
const start = new Date();
|
const start = new Date();
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
const { result } = await store.getEvents({ to: start, limit: 5, descending: true });
|
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);
|
if (done) done(false);
|
||||||
} else {
|
} else {
|
||||||
const len = events.value.length;
|
const len = events.value.length;
|
||||||
|
@ -108,7 +113,12 @@ export default defineComponent({
|
||||||
offset: (index - 1) * 10,
|
offset: (index - 1) * 10,
|
||||||
limit: 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);
|
if (done) return done(true);
|
||||||
} else if (done) done(false);
|
} else if (done) done(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue