This commit is contained in:
cutestnekoaqua 2023-01-18 23:48:05 +01:00
parent 58b2f7f138
commit 86bb42b529
No known key found for this signature in database
GPG Key ID: 6BF0964A5069C1E0
1 changed files with 4 additions and 13 deletions

View File

@ -278,17 +278,6 @@ const prepend = (item: Item): void => {
// Prepend the item // Prepend the item
items.value.unshift(item); items.value.unshift(item);
if(props.externalItemArray) props.externalItemArray.value.unshift(item); if(props.externalItemArray) props.externalItemArray.value.unshift(item);
//
if (items.value.length >= props.displayLimit) {
// Vue 3.2
//this.items = items.value.slice(0, props.displayLimit);
while (items.value.length >= props.displayLimit) {
items.value.pop();
if(props.externalItemArray) props.externalItemArray.value.pop();
}
more.value = true;
}
} else { } else {
queue.value.push(item); queue.value.push(item);
onScrollTop(rootEl.value, () => { onScrollTop(rootEl.value, () => {
@ -308,7 +297,8 @@ const append = (item: Item): void => {
const removeItem = (finder: (item: Item) => boolean): boolean => { const removeItem = (finder: (item: Item) => boolean): boolean => {
const i = items.value.findIndex(finder); const i = items.value.findIndex(finder);
if (i === -1) { const j = props.externalItemArray?.findIndex(finder);
if (i === -1 && j === -1) {
return false; return false;
} }
@ -319,7 +309,8 @@ const removeItem = (finder: (item: Item) => boolean): boolean => {
const updateItem = (id: Item['id'], replacer: (old: Item) => Item): boolean => { const updateItem = (id: Item['id'], replacer: (old: Item) => Item): boolean => {
const i = items.value.findIndex(item => item.id === id); const i = items.value.findIndex(item => item.id === id);
if (i === -1) { const j = props.externalItemArray?.findIndex(item => item.id === id);
if (i === -1 && j === -1) {
return false; return false;
} }