mirror of
https://github.com/schlagmichdoch/PairDrop.git
synced 2026-04-21 22:54:53 +08:00
fix PWA offline capability
This commit is contained in:
@@ -152,10 +152,9 @@ class ServerConnection {
|
||||
|
||||
_onDisconnect() {
|
||||
console.log('WS: server disconnected');
|
||||
Events.fire('notify-user', 'Server connection lost. Retrying...');
|
||||
Events.fire('notify-user', 'No server connection. Retry in 5s...');
|
||||
clearTimeout(this._reconnectTimer);
|
||||
this._reconnectTimer = setTimeout(_ => this._connect(), 5000);
|
||||
this._connect();
|
||||
Events.fire('ws-disconnected');
|
||||
}
|
||||
|
||||
|
||||
@@ -1220,7 +1220,7 @@ class NetworkStatusUI {
|
||||
Events.on('offline', _ => this._showOfflineMessage());
|
||||
Events.on('online', _ => this._showOnlineMessage());
|
||||
Events.on('ws-connected', _ => this._showOnlineMessage());
|
||||
Events.on('ws-disconnected', _ => window.animateBackground(false));
|
||||
Events.on('ws-disconnected', _ => this._onWsDisconnected());
|
||||
if (!navigator.onLine) this._showOfflineMessage();
|
||||
}
|
||||
|
||||
@@ -1230,12 +1230,17 @@ class NetworkStatusUI {
|
||||
}
|
||||
|
||||
_showOnlineMessage() {
|
||||
window.animateBackground(true);
|
||||
if (!this.firstConnect) {
|
||||
this.firstConnect = true;
|
||||
return;
|
||||
}
|
||||
Events.fire('notify-user', 'You are back online');
|
||||
window.animateBackground(true);
|
||||
}
|
||||
|
||||
_onWsDisconnected() {
|
||||
window.animateBackground(false);
|
||||
if (!this.firstConnect) this.firstConnect = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user