diff --git a/client/src/app.vue b/client/src/app.vue index d555544f..c2556efd 100644 --- a/client/src/app.vue +++ b/client/src/app.vue @@ -190,7 +190,7 @@ if (this.shakeKbd || this.$accessor.remote.hosted) return this.shakeKbd = true - setTimeout(() => (this.shakeKbd = false), 5000) + window.setTimeout(() => (this.shakeKbd = false), 5000) } get about() { diff --git a/client/src/components/clipboard.vue b/client/src/components/clipboard.vue index a1607e37..07b780f0 100644 --- a/client/src/components/clipboard.vue +++ b/client/src/components/clipboard.vue @@ -45,7 +45,7 @@ @Ref('textarea') readonly _textarea!: HTMLTextAreaElement private opened: boolean = false - private typing: any = null + private typing?: number get clipboard() { return this.$accessor.remote.clipboard @@ -56,15 +56,16 @@ if (this.typing) { clearTimeout(this.typing) + this.typing = undefined } - this.typing = setTimeout(() => this.$accessor.remote.sendClipboard(this.clipboard), 500) + this.typing = window.setTimeout(() => this.$accessor.remote.sendClipboard(this.clipboard), 500) } open() { this.opened = true document.body.addEventListener('click', this.close) - setTimeout(() => this._textarea.focus(), 0) + window.setTimeout(() => this._textarea.focus(), 0) } close() { diff --git a/client/src/neko/base.ts b/client/src/neko/base.ts index 46d7eff9..5a9d0428 100644 --- a/client/src/neko/base.ts +++ b/client/src/neko/base.ts @@ -15,7 +15,7 @@ export abstract class BaseClient extends EventEmitter { protected _ws?: WebSocket protected _peer?: RTCPeerConnection protected _channel?: RTCDataChannel - protected _timeout?: NodeJS.Timeout + protected _timeout?: number protected _displayname?: string protected _state: RTCIceConnectionState = 'disconnected' protected _id = '' @@ -65,7 +65,7 @@ export abstract class BaseClient extends EventEmitter { this._ws.onmessage = this.onMessage.bind(this) this._ws.onerror = (event) => this.onError.bind(this) this._ws.onclose = (event) => this.onDisconnected.bind(this, new Error('websocket closed')) - this._timeout = setTimeout(this.onTimeout.bind(this), 15000) + this._timeout = window.setTimeout(this.onTimeout.bind(this), 15000) } catch (err) { this.onDisconnected(err) } @@ -74,6 +74,7 @@ export abstract class BaseClient extends EventEmitter { protected disconnect() { if (this._timeout) { clearTimeout(this._timeout) + this._timeout = undefined } if (this._ws) { @@ -223,6 +224,7 @@ export abstract class BaseClient extends EventEmitter { case 'checking': if (this._timeout) { clearTimeout(this._timeout) + this._timeout = undefined } break case 'connected': @@ -325,6 +327,7 @@ export abstract class BaseClient extends EventEmitter { private onConnected() { if (this._timeout) { clearTimeout(this._timeout) + this._timeout = undefined } if (!this.connected) { @@ -340,6 +343,7 @@ export abstract class BaseClient extends EventEmitter { this.emit('debug', `connection timeout`) if (this._timeout) { clearTimeout(this._timeout) + this._timeout = undefined } this.onDisconnected(new Error('connection timeout')) }