frontend: fix reconnect timeout

This commit is contained in:
hippoz 2022-04-14 22:04:41 +03:00
parent e329c64eb7
commit fdbf6c9839
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -33,7 +33,6 @@ export default {
if (this.reconnectTimeout) { if (this.reconnectTimeout) {
clearTimeout(this.reconnectTimeout); clearTimeout(this.reconnectTimeout);
} }
this.reconnectDelay = 400;
}; };
this.ws.onmessage = (event) => { this.ws.onmessage = (event) => {
const payload = JSON.parse(event.data); const payload = JSON.parse(event.data);
@ -56,12 +55,16 @@ export default {
case GatewayPayloadType.Ready: { case GatewayPayloadType.Ready: {
this.user = payload.d.user; this.user = payload.d.user;
this.channels = payload.d.channels; this.channels = payload.d.channels;
this.reconnectDelay = 400;
break; break;
} }
} }
}; };
this.ws.onclose = () => { this.ws.onclose = () => {
if (this.reconnectDelay < 60000) {
this.reconnectDelay *= 2; this.reconnectDelay *= 2;
}
this.authenticated = false; this.authenticated = false;
this.user = null; this.user = null;
this.channels = null; this.channels = null;