mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-12-26 09:43:08 +02:00
test
This commit is contained in:
parent
f3a0839552
commit
d5b4fa7e50
1 changed files with 7 additions and 40 deletions
|
@ -51,7 +51,6 @@ import { i18n } from '@/i18n';
|
||||||
const SECOND_FETCH_LIMIT = 30;
|
const SECOND_FETCH_LIMIT = 30;
|
||||||
const TOLERANCE = 6;
|
const TOLERANCE = 6;
|
||||||
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,9 +158,6 @@ const scrollableElementOrHtml = $computed(() => scrollableElement ?? document.ge
|
||||||
|
|
||||||
const visibility = useDocumentVisibility();
|
const visibility = useDocumentVisibility();
|
||||||
|
|
||||||
const isPausingUpdateByVisibility = ref(false);
|
|
||||||
const timerForSetPause = ref<number | null>(null);
|
|
||||||
|
|
||||||
const isPausingUpdateByExecutingQueue = ref(false);
|
const isPausingUpdateByExecutingQueue = ref(false);
|
||||||
|
|
||||||
//#region scrolling
|
//#region scrolling
|
||||||
|
@ -346,10 +342,9 @@ const fetchMore = async (): Promise<void> => {
|
||||||
|
|
||||||
if (res.length === 0) {
|
if (res.length === 0) {
|
||||||
if (props.pagination.reversed) {
|
if (props.pagination.reversed) {
|
||||||
reverseConcat(res).then(() => {
|
reverseConcat(res);
|
||||||
more.value = false;
|
more.value = false;
|
||||||
moreFetching.value = false;
|
moreFetching.value = false;
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
items.value = concatMapWithArray(items.value, res);
|
items.value = concatMapWithArray(items.value, res);
|
||||||
more.value = false;
|
more.value = false;
|
||||||
|
@ -357,10 +352,9 @@ const fetchMore = async (): Promise<void> => {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (props.pagination.reversed) {
|
if (props.pagination.reversed) {
|
||||||
reverseConcat(res).then(() => {
|
reverseConcat(res);
|
||||||
more.value = true;
|
more.value = true;
|
||||||
moreFetching.value = false;
|
moreFetching.value = false;
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
items.value = concatMapWithArray(items.value, res);
|
items.value = concatMapWithArray(items.value, res);
|
||||||
more.value = true;
|
more.value = true;
|
||||||
|
@ -425,30 +419,9 @@ const appearFetchMoreAhead = async (): Promise<void> => {
|
||||||
fetchMoreAppearTimeout();
|
fetchMoreAppearTimeout();
|
||||||
};
|
};
|
||||||
|
|
||||||
function visibilityChange() {
|
|
||||||
if (visibility.value === 'hidden') {
|
|
||||||
timerForSetPause.value = window.setTimeout(() => {
|
|
||||||
isPausingUpdateByVisibility.value = true;
|
|
||||||
timerForSetPause.value = null;
|
|
||||||
},
|
|
||||||
BACKGROUND_PAUSE_WAIT_SEC * 1000);
|
|
||||||
} else { // 'visible'
|
|
||||||
if (timerForSetPause.value) {
|
|
||||||
clearTimeout(timerForSetPause.value);
|
|
||||||
timerForSetPause.value = null;
|
|
||||||
} else {
|
|
||||||
isPausingUpdateByVisibility.value = false;
|
|
||||||
if (!backed && active.value) {
|
|
||||||
executeQueue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
onActivated(() => {
|
onActivated(() => {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
active.value = true;
|
active.value = true;
|
||||||
visibilityChange();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -456,8 +429,6 @@ onDeactivated(() => {
|
||||||
active.value = false;
|
active.value = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(visibility, visibilityChange);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 最新のものとして1つだけアイテムを追加する
|
* 最新のものとして1つだけアイテムを追加する
|
||||||
* ストリーミングから降ってきたアイテムはこれで追加する
|
* ストリーミングから降ってきたアイテムはこれで追加する
|
||||||
|
@ -478,7 +449,7 @@ const prepend = (item: MisskeyEntity): void => {
|
||||||
if (!backed) {
|
if (!backed) {
|
||||||
// かなりスクロールの先頭にいる場合
|
// かなりスクロールの先頭にいる場合
|
||||||
if (items.value.has(item.id)) return; // 既にタイムラインにある場合は何もしない
|
if (items.value.has(item.id)) return; // 既にタイムラインにある場合は何もしない
|
||||||
if (isPausingUpdateByVisibility.value) {
|
if (visibility.value === 'hidden') {
|
||||||
// バックグラウンドかつスクロールの先頭にいる場合は
|
// バックグラウンドかつスクロールの先頭にいる場合は
|
||||||
// prependQueueしつつちょっと特殊な処理を挟む…
|
// prependQueueしつつちょっと特殊な処理を挟む…
|
||||||
prependQueue(item);
|
prependQueue(item);
|
||||||
|
@ -573,10 +544,6 @@ onMounted(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeUnmount(() => {
|
onBeforeUnmount(() => {
|
||||||
if (timerForSetPause.value) {
|
|
||||||
clearTimeout(timerForSetPause.value);
|
|
||||||
timerForSetPause.value = null;
|
|
||||||
}
|
|
||||||
if (preventAppearFetchMoreTimer.value) {
|
if (preventAppearFetchMoreTimer.value) {
|
||||||
clearTimeout(preventAppearFetchMoreTimer.value);
|
clearTimeout(preventAppearFetchMoreTimer.value);
|
||||||
preventAppearFetchMoreTimer.value = null;
|
preventAppearFetchMoreTimer.value = null;
|
||||||
|
|
Loading…
Reference in a new issue