mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2025-04-23 00:06:18 -04:00
Make "Connecting..." toast persistent until connection is established
This commit is contained in:
parent
4e00e5b358
commit
684fe7142d
4 changed files with 28 additions and 14 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue