This commit is contained in:
tamaina 2023-07-13 04:15:32 +00:00
parent af00c2c96c
commit 88315d3e80

View file

@ -231,7 +231,7 @@ watch([$$(weakBacked), $$(contentEl)], () => {
* アイテムを上に追加した場合に追加分だけスクロールを下にずらす * アイテムを上に追加した場合に追加分だけスクロールを下にずらす
* @param fn DOM操作(unshiftItemsなどで) * @param fn DOM操作(unshiftItemsなどで)
*/ */
function adjustScroll(fn: () => void) { function adjustScroll(fn: () => void): Promise<void> {
const oldHeight = scrollableElement.scrollHeight; const oldHeight = scrollableElement.scrollHeight;
const oldScroll = scrollableElement.scrollTop; const oldScroll = scrollableElement.scrollTop;
fn(); fn();
@ -493,7 +493,7 @@ const prepend = (item: MisskeyEntity): void => {
if ( if (
queueSize.value === 0 && // queueSize.value === 0 && //
!backed && // !backed && //
!isPausingUpdate && // !isPausingUpdate && // /調
active.value // keepAlive active.value // keepAlive
) { ) {
if (items.value.has(item.id)) return; // if (items.value.has(item.id)) return; //
@ -528,15 +528,17 @@ function concatItems(oldItems: MisskeyEntity[]) {
async function executeQueue() { async function executeQueue() {
const queueArr = Array.from(queue.value.entries()); const queueArr = Array.from(queue.value.entries());
adjustScroll(() => { queue.value = new Map(queueArr.slice(props.pagination.limit));
isPausingUpdate = true;
await adjustScroll(() => {
unshiftItems( unshiftItems(
queueArr.slice(0, props.pagination.limit).map(v => v[1]).reverse(), queueArr.slice(0, props.pagination.limit).map(v => v[1]).reverse(),
Infinity, Infinity,
); );
}).then(() => {
items.value = new Map([...items.value].slice(0, displayLimit.value));
}); });
queue.value = new Map(queueArr.slice(props.pagination.limit)); items.value = new Map([...items.value].slice(0, displayLimit.value));
await nextTick();
isPausingUpdate = false;
} }
function prependQueue(newItem: MisskeyEntity) { function prependQueue(newItem: MisskeyEntity) {