From 5666bb4622bc4abc73f800c43a59458e9103baa5 Mon Sep 17 00:00:00 2001 From: Natty Date: Mon, 25 Nov 2024 19:39:05 +0100 Subject: [PATCH] Frontend: Fixed prepending items when fresh and full --- .../frontend/client/src/components/MkPagination.vue | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fe_calckey/frontend/client/src/components/MkPagination.vue b/fe_calckey/frontend/client/src/components/MkPagination.vue index 137ecbe..4f2cd85 100644 --- a/fe_calckey/frontend/client/src/components/MkPagination.vue +++ b/fe_calckey/frontend/client/src/components/MkPagination.vue @@ -197,7 +197,7 @@ const refresh = async (): Promise => { for (let i = 0; i < res.length; i++) { const item = res[i]; if (!updateItem(item.id, (old) => item)) { - append(item); + prepend(item); } ids.delete(item.id); } @@ -314,9 +314,7 @@ const prepend = (item: Item): void => { if (!queue.value.length) { (props.pagination.reversed ? onScrollBottom : onScrollTop)( rootEl.value, - () => { - nextTick(unqueue); - } + unqueue ); } @@ -325,11 +323,11 @@ const prepend = (item: Item): void => { return; } - if (items.value.length > props.displayLimit) { - queue.value = [...queue.value, item].slice(-props.displayLimit); + if (items.value.length >= props.displayLimit) { if (!queue.value.length) { nextTick(unqueue); } + queue.value = [...queue.value, item].slice(-props.displayLimit); return; }