mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
fix timeout typescript.
This commit is contained in:
parent
45ef058bf4
commit
38bed98741
@ -190,7 +190,7 @@
|
|||||||
if (this.shakeKbd || this.$accessor.remote.hosted) return
|
if (this.shakeKbd || this.$accessor.remote.hosted) return
|
||||||
|
|
||||||
this.shakeKbd = true
|
this.shakeKbd = true
|
||||||
setTimeout(() => (this.shakeKbd = false), 5000)
|
window.setTimeout(() => (this.shakeKbd = false), 5000)
|
||||||
}
|
}
|
||||||
|
|
||||||
get about() {
|
get about() {
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
@Ref('textarea') readonly _textarea!: HTMLTextAreaElement
|
@Ref('textarea') readonly _textarea!: HTMLTextAreaElement
|
||||||
|
|
||||||
private opened: boolean = false
|
private opened: boolean = false
|
||||||
private typing: any = null
|
private typing?: number
|
||||||
|
|
||||||
get clipboard() {
|
get clipboard() {
|
||||||
return this.$accessor.remote.clipboard
|
return this.$accessor.remote.clipboard
|
||||||
@ -56,15 +56,16 @@
|
|||||||
|
|
||||||
if (this.typing) {
|
if (this.typing) {
|
||||||
clearTimeout(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() {
|
open() {
|
||||||
this.opened = true
|
this.opened = true
|
||||||
document.body.addEventListener('click', this.close)
|
document.body.addEventListener('click', this.close)
|
||||||
setTimeout(() => this._textarea.focus(), 0)
|
window.setTimeout(() => this._textarea.focus(), 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
close() {
|
close() {
|
||||||
|
@ -15,7 +15,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
|||||||
protected _ws?: WebSocket
|
protected _ws?: WebSocket
|
||||||
protected _peer?: RTCPeerConnection
|
protected _peer?: RTCPeerConnection
|
||||||
protected _channel?: RTCDataChannel
|
protected _channel?: RTCDataChannel
|
||||||
protected _timeout?: NodeJS.Timeout
|
protected _timeout?: number
|
||||||
protected _displayname?: string
|
protected _displayname?: string
|
||||||
protected _state: RTCIceConnectionState = 'disconnected'
|
protected _state: RTCIceConnectionState = 'disconnected'
|
||||||
protected _id = ''
|
protected _id = ''
|
||||||
@ -65,7 +65,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
|||||||
this._ws.onmessage = this.onMessage.bind(this)
|
this._ws.onmessage = this.onMessage.bind(this)
|
||||||
this._ws.onerror = (event) => this.onError.bind(this)
|
this._ws.onerror = (event) => this.onError.bind(this)
|
||||||
this._ws.onclose = (event) => this.onDisconnected.bind(this, new Error('websocket closed'))
|
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) {
|
} catch (err) {
|
||||||
this.onDisconnected(err)
|
this.onDisconnected(err)
|
||||||
}
|
}
|
||||||
@ -74,6 +74,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
|||||||
protected disconnect() {
|
protected disconnect() {
|
||||||
if (this._timeout) {
|
if (this._timeout) {
|
||||||
clearTimeout(this._timeout)
|
clearTimeout(this._timeout)
|
||||||
|
this._timeout = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this._ws) {
|
if (this._ws) {
|
||||||
@ -223,6 +224,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
|||||||
case 'checking':
|
case 'checking':
|
||||||
if (this._timeout) {
|
if (this._timeout) {
|
||||||
clearTimeout(this._timeout)
|
clearTimeout(this._timeout)
|
||||||
|
this._timeout = undefined
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
case 'connected':
|
case 'connected':
|
||||||
@ -325,6 +327,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
|||||||
private onConnected() {
|
private onConnected() {
|
||||||
if (this._timeout) {
|
if (this._timeout) {
|
||||||
clearTimeout(this._timeout)
|
clearTimeout(this._timeout)
|
||||||
|
this._timeout = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!this.connected) {
|
if (!this.connected) {
|
||||||
@ -340,6 +343,7 @@ export abstract class BaseClient extends EventEmitter<BaseEvents> {
|
|||||||
this.emit('debug', `connection timeout`)
|
this.emit('debug', `connection timeout`)
|
||||||
if (this._timeout) {
|
if (this._timeout) {
|
||||||
clearTimeout(this._timeout)
|
clearTimeout(this._timeout)
|
||||||
|
this._timeout = undefined
|
||||||
}
|
}
|
||||||
this.onDisconnected(new Error('connection timeout'))
|
this.onDisconnected(new Error('connection timeout'))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user