From 981e6f996ec632f4ccb27d24d107c37a5d070b32 Mon Sep 17 00:00:00 2001 From: syuilo Date: Tue, 6 Jun 2023 09:04:57 +0900 Subject: [PATCH] =?UTF-8?q?fix(frontend):=20=E3=82=BF=E3=83=96=E3=81=8C?= =?UTF-8?q?=E3=82=A2=E3=82=AF=E3=83=86=E3=82=A3=E3=83=96=E3=81=AA=E9=96=93?= =?UTF-8?q?=E3=81=AFstream=E3=81=8C=E5=88=87=E6=96=AD=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=AA=E3=81=84=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix #10952 --- CHANGELOG.md | 3 +++ packages/frontend/src/stream.ts | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 429628878..cc13749ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ ## 13.13.1 (unreleased) +### Client +- Fix: タブがアクティブな間はstreamが切断されないように + ### Server - Fix: api/metaで`TypeError: JSON5.parse is not a function`エラーが発生する問題を修正 diff --git a/packages/frontend/src/stream.ts b/packages/frontend/src/stream.ts index 9cae58a26..a807d1d30 100644 --- a/packages/frontend/src/stream.ts +++ b/packages/frontend/src/stream.ts @@ -12,5 +12,14 @@ export function useStream(): Misskey.Stream { token: $i.token, } : null)); + window.setTimeout(heartbeat, 1000 * 60); + return stream; } + +function heartbeat(): void { + if (stream != null && document.visibilityState === 'visible') { + stream.send('ping'); + } + window.setTimeout(heartbeat, 1000 * 60); +}