サーバーから切断された後 stream indicator をすぐに表示しないようにする (MisskeyIO#172)

すぐに再接続されたら表示しないように
This commit is contained in:
riku6460 2023-10-06 21:57:37 +09:00 committed by GitHub
parent b784983a8e
commit 3717666807
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -24,12 +24,17 @@ import { defaultStore } from '@/store';
const zIndex = os.claimZIndex('high');
let hasDisconnected = $ref(false);
let timeoutId = $ref<number>();
function onDisconnected() {
hasDisconnected = true;
window.clearTimeout(timeoutId);
timeoutId = window.setTimeout(() => {
hasDisconnected = true;
}, 1000 * 10);
}
function resetDisconnected() {
window.clearTimeout(timeoutId);
hasDisconnected = false;
}
@ -37,9 +42,12 @@ function reload() {
location.reload();
}
useStream().on('_connected_', resetDisconnected);
useStream().on('_disconnected_', onDisconnected);
onUnmounted(() => {
window.clearTimeout(timeoutId);
useStream().off('_connected_', resetDisconnected);
useStream().off('_disconnected_', onDisconnected);
});
</script>