fix(paginator): item count less than buffer

This commit is contained in:
三咲智子 2023-01-09 23:20:54 +08:00
parent 01a24a6015
commit 333cab0858
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
1 changed files with 4 additions and 1 deletions

View File

@ -66,7 +66,10 @@ export function usePaginator<T, P, U = T>(
if (result.value?.length) {
const preprocessedItems = preprocess([...nextItems.value, ...result.value]) as any
const itemsToShowCount = preprocessedItems.length - buffer
const itemsToShowCount
= preprocessedItems.length < buffer
? preprocessedItems.length
: preprocessedItems.length - buffer
nextItems.value = preprocessedItems.slice(itemsToShowCount)
items.value.push(...preprocessedItems.slice(0, itemsToShowCount))
state.value = 'idle'