fix(frontend): eventListener leak
All checks were successful
Lint / pnpm_install (pull_request) Successful in 1m27s
Test (production install and build) / production (20.16.0) (pull_request) Successful in 1m40s
Lint / lint (backend) (pull_request) Successful in 2m9s
Publish Docker image / Build (pull_request) Successful in 4m40s
Lint / lint (frontend) (pull_request) Successful in 2m33s
Lint / lint (frontend-embed) (pull_request) Successful in 2m34s
Lint / lint (frontend-shared) (pull_request) Successful in 2m22s
Lint / lint (misskey-bubble-game) (pull_request) Successful in 2m29s
Lint / lint (misskey-js) (pull_request) Successful in 2m29s
Lint / lint (misskey-reversi) (pull_request) Successful in 2m23s
Lint / lint (sw) (pull_request) Successful in 2m23s
Lint / typecheck (misskey-js) (pull_request) Successful in 1m26s
Lint / typecheck (backend) (pull_request) Successful in 2m25s
Lint / typecheck (sw) (pull_request) Successful in 1m31s
All checks were successful
Lint / pnpm_install (pull_request) Successful in 1m27s
Test (production install and build) / production (20.16.0) (pull_request) Successful in 1m40s
Lint / lint (backend) (pull_request) Successful in 2m9s
Publish Docker image / Build (pull_request) Successful in 4m40s
Lint / lint (frontend) (pull_request) Successful in 2m33s
Lint / lint (frontend-embed) (pull_request) Successful in 2m34s
Lint / lint (frontend-shared) (pull_request) Successful in 2m22s
Lint / lint (misskey-bubble-game) (pull_request) Successful in 2m29s
Lint / lint (misskey-js) (pull_request) Successful in 2m29s
Lint / lint (misskey-reversi) (pull_request) Successful in 2m23s
Lint / lint (sw) (pull_request) Successful in 2m23s
Lint / typecheck (misskey-js) (pull_request) Successful in 1m26s
Lint / typecheck (backend) (pull_request) Successful in 2m25s
Lint / typecheck (sw) (pull_request) Successful in 1m31s
Signed-off-by: eternal-flame-AD <yume@yumechi.jp>
This commit is contained in:
parent
e74174dea3
commit
997c5b3d35
1 changed files with 8 additions and 2 deletions
|
@ -68,14 +68,20 @@ export function useStream(): Misskey.IStream {
|
|||
if (timeoutHeartBeat) window.clearTimeout(timeoutHeartBeat);
|
||||
timeoutHeartBeat = window.setTimeout(heartbeat, HEART_BEAT_INTERVAL);
|
||||
|
||||
// send heartbeat right now when last send time is over HEART_BEAT_INTERVAL
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
const target = () => {
|
||||
if (
|
||||
!stream
|
||||
|| document.visibilityState !== 'visible'
|
||||
|| Date.now() - lastHeartbeatCall < HEART_BEAT_INTERVAL
|
||||
) return;
|
||||
heartbeat();
|
||||
};
|
||||
|
||||
// send heartbeat right now when last send time is over HEART_BEAT_INTERVAL
|
||||
document.addEventListener('visibilitychange', target);
|
||||
|
||||
stream.on('_disconnected_', () => {
|
||||
document.removeEventListener('visibilitychange', target);
|
||||
});
|
||||
|
||||
return stream;
|
||||
|
|
Loading…
Reference in a new issue