summaryrefslogtreecommitdiff
path: root/packages/frontend/src/stream.ts
diff options
context:
space:
mode:
author_ <phy.public@gmail.com>2023-10-30 09:12:20 +0900
committerGitHub <noreply@github.com>2023-10-30 09:12:20 +0900
commitc239058624dcd880ec1c5f3c436f3a2a06fc22c3 (patch)
tree1ffe780569e2535337d3bebdff1d562b90922dcf /packages/frontend/src/stream.ts
parentfix(backend): プロフィールの自己紹介欄のMFMを連合するよう... (diff)
downloadmisskey-c239058624dcd880ec1c5f3c436f3a2a06fc22c3.tar.gz
misskey-c239058624dcd880ec1c5f3c436f3a2a06fc22c3.tar.bz2
misskey-c239058624dcd880ec1c5f3c436f3a2a06fc22c3.zip
feat(frontend): スワイプやボタンでタイムラインを再読込する機能 (#12113)
* pc reloading * add: disable TL websocket option * fix: stream disconnect when reload * add: pull to refresh * fix: pull to refresh * add changelog * fact: change to disableStreamingTimeline * lint * remove: en-US text * refactor * refactor * add license identifier * tweak * Update MkPullToRefresh.vue * Update MkPullToRefresh.vue * change name timeoutHeartBeat * tweak * :art: --------- Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
Diffstat (limited to 'packages/frontend/src/stream.ts')
-rw-r--r--packages/frontend/src/stream.ts20
1 files changed, 18 insertions, 2 deletions
diff --git a/packages/frontend/src/stream.ts b/packages/frontend/src/stream.ts
index 27fce4d4b8..1e2d31480c 100644
--- a/packages/frontend/src/stream.ts
+++ b/packages/frontend/src/stream.ts
@@ -9,6 +9,9 @@ import { $i } from '@/account.js';
import { url } from '@/config.js';
let stream: Misskey.Stream | null = null;
+let timeoutHeartBeat: number | null = null;
+
+export let isReloading: boolean = false;
export function useStream(): Misskey.Stream {
if (stream) return stream;
@@ -17,7 +20,20 @@ export function useStream(): Misskey.Stream {
token: $i.token,
} : null));
- window.setTimeout(heartbeat, 1000 * 60);
+ timeoutHeartBeat = window.setTimeout(heartbeat, 1000 * 60);
+
+ return stream;
+}
+
+export function reloadStream() {
+ if (!stream) return useStream();
+ if (timeoutHeartBeat) window.clearTimeout(timeoutHeartBeat);
+ isReloading = true;
+
+ stream.close();
+ stream.once('_connected_', () => isReloading = false);
+ stream.stream.reconnect();
+ timeoutHeartBeat = window.setTimeout(heartbeat, 1000 * 60);
return stream;
}
@@ -26,5 +42,5 @@ function heartbeat(): void {
if (stream != null && document.visibilityState === 'visible') {
stream.heartbeat();
}
- window.setTimeout(heartbeat, 1000 * 60);
+ timeoutHeartBeat = window.setTimeout(heartbeat, 1000 * 60);
}