diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2025-07-03 18:52:16 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-07-03 18:52:16 +0900 |
| commit | 179d990c39ed5c7f79e7481ca86b07ec9f70d474 (patch) | |
| tree | 6210475837a0c413eceecf9d6e5a30ee9ac8c6d9 /packages/frontend/src/components/MkStreamingNotesTimeline.vue | |
| parent | enhance(backend): avatarUrlの上限文字数の引き上げ (#16235) (diff) | |
| download | misskey-179d990c39ed5c7f79e7481ca86b07ec9f70d474.tar.gz misskey-179d990c39ed5c7f79e7481ca86b07ec9f70d474.tar.bz2 misskey-179d990c39ed5c7f79e7481ca86b07ec9f70d474.zip | |
fix(frontend): タブが不可視なあいだのpaginationのアップデートを停止するように (#16243)
* fix(frontend): タブが不可視なあいだのpaginationのアップデートを停止するように
* fix lint
* 待たない
Diffstat (limited to 'packages/frontend/src/components/MkStreamingNotesTimeline.vue')
| -rw-r--r-- | packages/frontend/src/components/MkStreamingNotesTimeline.vue | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/packages/frontend/src/components/MkStreamingNotesTimeline.vue b/packages/frontend/src/components/MkStreamingNotesTimeline.vue index b697e18f79..44f873b6e3 100644 --- a/packages/frontend/src/components/MkStreamingNotesTimeline.vue +++ b/packages/frontend/src/components/MkStreamingNotesTimeline.vue @@ -59,6 +59,7 @@ SPDX-License-Identifier: AGPL-3.0-only import { computed, watch, onUnmounted, provide, useTemplateRef, TransitionGroup, onMounted, shallowRef, ref, markRaw } from 'vue'; import * as Misskey from 'misskey-js'; import { useInterval } from '@@/js/use-interval.js'; +import { useDocumentVisibility } from '@@/js/use-document-visibility.js'; import { getScrollContainer, scrollToTop } from '@@/js/scroll.js'; import type { BasicTimelineType } from '@/timelines.js'; import type { SoundStore } from '@/preferences/def.js'; @@ -224,6 +225,20 @@ onUnmounted(() => { } }); +const visibility = useDocumentVisibility(); +let isPausingUpdate = false; + +watch(visibility, () => { + if (visibility.value === 'hidden') { + isPausingUpdate = true; + } else { // 'visible' + isPausingUpdate = false; + if (isTop()) { + releaseQueue(); + } + } +}); + let adInsertionCounter = 0; const MIN_POLLING_INTERVAL = 1000 * 10; @@ -237,7 +252,7 @@ if (!store.s.realtimeMode) { // TODO: 先頭のノートの作成日時が1日以上前であれば流速が遅いTLと見做してインターバルを通常より延ばす useInterval(async () => { paginator.fetchNewer({ - toQueue: !isTop(), + toQueue: !isTop() || isPausingUpdate, }); }, POLLING_INTERVAL, { immediate: false, @@ -246,7 +261,7 @@ if (!store.s.realtimeMode) { useGlobalEvent('notePosted', (note) => { paginator.fetchNewer({ - toQueue: !isTop(), + toQueue: !isTop() || isPausingUpdate, }); }); } @@ -257,7 +272,7 @@ useGlobalEvent('noteDeleted', (noteId) => { function releaseQueue() { paginator.releaseQueue(); - scrollToTop(rootEl.value); + scrollToTop(rootEl.value!); } function prepend(note: Misskey.entities.Note & MisskeyEntity) { @@ -267,7 +282,7 @@ function prepend(note: Misskey.entities.Note & MisskeyEntity) { note._shouldInsertAd_ = true; } - if (isTop()) { + if (isTop() && !isPausingUpdate) { paginator.prepend(note); } else { paginator.enqueue(note); |