Remove empty event trigger, doesn't seem to be required any more but could be wrong
This commit is contained in:
parent
9dae805017
commit
7dd155eb16
|
@ -6,6 +6,8 @@
|
|||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
const DISCONNECTED_DELAY = 30000;
|
||||
|
||||
Whisper.NetworkStatusView = Whisper.View.extend({
|
||||
className: 'network-status',
|
||||
templateName: 'networkStatus',
|
||||
|
@ -27,6 +29,7 @@
|
|||
|
||||
this.model = new Backbone.Model();
|
||||
this.listenTo(this.model, 'change', this.onChange);
|
||||
this.connectedTimer = null;
|
||||
},
|
||||
onReconnectTimer() {
|
||||
this.setSocketReconnectInterval(60000);
|
||||
|
@ -55,20 +58,34 @@
|
|||
case WebSocket.CONNECTING:
|
||||
message = i18n('connecting');
|
||||
this.setSocketReconnectInterval(null);
|
||||
window.clearTimeout(this.connectedTimer);
|
||||
this.connectedTimer = null;
|
||||
break;
|
||||
case WebSocket.OPEN:
|
||||
this.setSocketReconnectInterval(null);
|
||||
window.clearTimeout(this.connectedTimer);
|
||||
this.connectedTimer = null;
|
||||
break;
|
||||
case WebSocket.CLOSED:
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
if (!this.connectedTimer) {
|
||||
// Mark offline if disconnected for 30 seconds
|
||||
this.connectedTimer = window.setTimeout(() => {
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
}, DISCONNECTED_DELAY);
|
||||
}
|
||||
break;
|
||||
case WebSocket.CLOSING:
|
||||
default:
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
if (!this.connectedTimer) {
|
||||
// Mark offline if disconnected for 30 seconds
|
||||
this.connectedTimer = window.setTimeout(() => {
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
}, DISCONNECTED_DELAY);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -83,8 +83,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
// Note: calling callback(false) is currently not necessary
|
||||
this.pollServer = async callback => {
|
||||
this.pollServer = async () => {
|
||||
// This blocking call will return only when all attempts
|
||||
// at reaching snodes are exhausted or a DNS error occured
|
||||
try {
|
||||
|
@ -93,7 +92,6 @@
|
|||
stopPolling,
|
||||
messages => {
|
||||
connected = true;
|
||||
callback(connected);
|
||||
messages.forEach(message => {
|
||||
const { data } = message;
|
||||
this.handleMessage(data);
|
||||
|
@ -111,7 +109,7 @@
|
|||
connected = false;
|
||||
// Exhausted all our snodes urls, trying again later from scratch
|
||||
setTimeout(() => {
|
||||
this.pollServer(callback);
|
||||
this.pollServer();
|
||||
}, EXHAUSTED_SNODES_RETRY_DELAY);
|
||||
};
|
||||
|
||||
|
|
|
@ -73,16 +73,7 @@ MessageReceiver.prototype.extend({
|
|||
this.httpPollingResource = new HttpResource(lokiMessageAPI, {
|
||||
handleRequest: this.handleRequest.bind(this),
|
||||
});
|
||||
this.httpPollingResource.pollServer(connected => {
|
||||
// Emulate receiving an 'empty' websocket messages from the server.
|
||||
// This is required to update the internal logic that checks
|
||||
// if we are connected to the server. Without this, for example,
|
||||
// the loading screen would never disappear if the navigator
|
||||
// detects internet connectivity but never receives an 'empty' signal.
|
||||
if (connected) {
|
||||
this.onEmpty();
|
||||
}
|
||||
});
|
||||
this.httpPollingResource.pollServer();
|
||||
localLokiServer.on('message', this.handleP2pMessage.bind(this));
|
||||
this.startLocalServer();
|
||||
|
||||
|
|
Loading…
Reference in New Issue