This commit is contained in:
tamaina 2023-07-14 12:03:59 +00:00
parent 7d4f33d2c0
commit 04ff07e4e7

View file

@ -49,8 +49,10 @@ import { MisskeyEntity } from '@/types/date-separated-list';
import { i18n } from '@/i18n'; import { i18n } from '@/i18n';
const SECOND_FETCH_LIMIT = 30; const SECOND_FETCH_LIMIT = 30;
const TOLERANCE = 256; const BACK_TO_TOP_TOLERANCE = 256;
const TOP_STATIC_TOLERANCE = 64;
const APPEAR_MINIMUM_INTERVAL = 600; const APPEAR_MINIMUM_INTERVAL = 600;
const BACKGROUND_PAUSE_WAIT_SEC = 10;
export type Paging<E extends keyof misskey.Endpoints = keyof misskey.Endpoints> = { export type Paging<E extends keyof misskey.Endpoints = keyof misskey.Endpoints> = {
endpoint: E; endpoint: E;
@ -159,14 +161,13 @@ const visibility = useDocumentVisibility();
const isPausingUpdate = ref(false); const isPausingUpdate = ref(false);
const timerForSetPause = ref<number | null>(null); const timerForSetPause = ref<number | null>(null);
const BACKGROUND_PAUSE_WAIT_SEC = 10;
//#region scrolling //#region scrolling
const checkFn = props.pagination.reversed ? isBottomVisible : isTopVisible; const checkFn = props.pagination.reversed ? isBottomVisible : isTopVisible;
const checkTop = () => { const checkTop = (tolerance?: number) => {
if (!contentEl) return; if (!contentEl) return;
if (!document.body.contains(contentEl)) return; if (!document.body.contains(contentEl)) return;
return checkFn(contentEl, TOLERANCE, scrollableElement); return checkFn(contentEl, tolerance, scrollableElement);
}; };
/** /**
* IntersectionObserverで大まかに検出 * IntersectionObserverで大まかに検出
@ -217,7 +218,7 @@ watch([$$(weakBacked), $$(contentEl)], () => {
console.log('weakBacked watcher add scrollRemove', weakBacked, contentEl); console.log('weakBacked watcher add scrollRemove', weakBacked, contentEl);
scrollRemove = (() => { scrollRemove = (() => {
const checkBacked = () => { const checkBacked = () => {
backed = !checkTop(); backed = !checkTop(BACK_TO_TOP_TOLERANCE);
console.log('checkBacked', backed); console.log('checkBacked', backed);
}; };
@ -508,10 +509,10 @@ const prepend = (item: MisskeyEntity): void => {
} }
if ( if (
queueSize.value === 0 && //
!backed && //
!isPausingUpdate.value && // /調 !isPausingUpdate.value && // /調
active.value // keepAlive queueSize.value === 0 && //
active.value && // keepAlive
checkTop(TOP_STATIC_TOLERANCE) //
) { ) {
if (items.value.has(item.id)) return; // if (items.value.has(item.id)) return; //
unshiftItems([item]); unshiftItems([item]);
@ -558,7 +559,7 @@ async function executeQueue() {
}); });
// backed // backed
weakBacked = !checkTop(); weakBacked = !checkTop(BACK_TO_TOP_TOLERANCE);
// adjustScroll // adjustScroll
denyMoveTransition.value = true; denyMoveTransition.value = true;