mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-04-06 01:43:48 +00:00
Make "Connecting..." toast persistent until connection is established
This commit is contained in:
@@ -38,6 +38,12 @@ class ServerConnection {
|
||||
_connect() {
|
||||
clearTimeout(this._reconnectTimer);
|
||||
if (this._isConnected() || this._isConnecting()) return;
|
||||
if (this._isReconnect) {
|
||||
Events.fire('notify-user', {
|
||||
message: Localization.getTranslation("notifications.connecting"),
|
||||
persistent: true
|
||||
});
|
||||
}
|
||||
const ws = new WebSocket(this._endpoint());
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = _ => this._onOpen();
|
||||
@@ -221,12 +227,10 @@ class ServerConnection {
|
||||
_onDisconnect() {
|
||||
console.log('WS: server disconnected');
|
||||
setTimeout(() => {
|
||||
Events.fire('notify-user', Localization.getTranslation("notifications.connecting"));
|
||||
this._isReconnect = true;
|
||||
Events.fire('ws-disconnected');
|
||||
this._reconnectTimer = setTimeout(_ => this._connect(), 1000);
|
||||
}, 100); //delay for 100ms to prevent flickering on page reload
|
||||
clearTimeout(this._reconnectTimer);
|
||||
this._reconnectTimer = setTimeout(_ => this._connect(), 1000);
|
||||
Events.fire('ws-disconnected');
|
||||
this._isReconnect = true;
|
||||
}
|
||||
|
||||
_onVisibilityChange() {
|
||||
|
||||
@@ -2044,9 +2044,12 @@ class Toast extends Dialog {
|
||||
|
||||
_onNotify(message) {
|
||||
if (this.hideTimeout) clearTimeout(this.hideTimeout);
|
||||
this.$el.innerText = message;
|
||||
this.$el.innerText = typeof message === "object" ? message.message : message;
|
||||
this.show();
|
||||
this.hideTimeout = setTimeout(_ => this.hide(), 5000);
|
||||
|
||||
if (typeof message === "object" && message.persistent) return;
|
||||
|
||||
this.hideTimeout = setTimeout(() => this.hide(), 5000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,12 @@ class ServerConnection {
|
||||
_connect() {
|
||||
clearTimeout(this._reconnectTimer);
|
||||
if (this._isConnected() || this._isConnecting()) return;
|
||||
if (this._isReconnect) {
|
||||
Events.fire('notify-user', {
|
||||
message: Localization.getTranslation("notifications.connecting"),
|
||||
persistent: true
|
||||
});
|
||||
}
|
||||
const ws = new WebSocket(this._endpoint());
|
||||
ws.binaryType = 'arraybuffer';
|
||||
ws.onopen = _ => this._onOpen();
|
||||
@@ -232,12 +238,10 @@ class ServerConnection {
|
||||
_onDisconnect() {
|
||||
console.log('WS: server disconnected');
|
||||
setTimeout(() => {
|
||||
Events.fire('notify-user', Localization.getTranslation("notifications.connecting"));
|
||||
this._isReconnect = true;
|
||||
Events.fire('ws-disconnected');
|
||||
this._reconnectTimer = setTimeout(_ => this._connect(), 1000);
|
||||
}, 100); //delay for 100ms to prevent flickering on page reload
|
||||
clearTimeout(this._reconnectTimer);
|
||||
this._reconnectTimer = setTimeout(_ => this._connect(), 1000);
|
||||
Events.fire('ws-disconnected');
|
||||
this._isReconnect = true;
|
||||
}
|
||||
|
||||
_onVisibilityChange() {
|
||||
|
||||
@@ -2046,9 +2046,12 @@ class Toast extends Dialog {
|
||||
|
||||
_onNotify(message) {
|
||||
if (this.hideTimeout) clearTimeout(this.hideTimeout);
|
||||
this.$el.innerText = message;
|
||||
this.$el.innerText = typeof message === "object" ? message.message : message;
|
||||
this.show();
|
||||
this.hideTimeout = setTimeout(_ => this.hide(), 5000);
|
||||
|
||||
if (typeof message === "object" && message.persistent) return;
|
||||
|
||||
this.hideTimeout = setTimeout(() => this.hide(), 5000);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user