Move all status/alert dialogs into the Left Pane
This commit is contained in:
parent
101070bf42
commit
18fd44f504
50 changed files with 1298 additions and 607 deletions
|
@ -29,7 +29,6 @@
|
|||
});
|
||||
},
|
||||
events: {
|
||||
'click .openInstaller': 'openInstaller', // NetworkStatusView has this button
|
||||
openInbox: 'openInbox',
|
||||
},
|
||||
applyTheme() {
|
||||
|
|
|
@ -2642,7 +2642,7 @@
|
|||
this.model.clearTypingTimers();
|
||||
|
||||
let ToastView;
|
||||
if (extension.expired()) {
|
||||
if (window.reduxStore.getState().expiration.hasExpired) {
|
||||
ToastView = Whisper.ExpiredToast;
|
||||
}
|
||||
if (this.model.isPrivate() && storage.isBlocked(this.model.id)) {
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
/* global
|
||||
ConversationController,
|
||||
extension,
|
||||
getInboxCollection,
|
||||
i18n,
|
||||
Whisper,
|
||||
Signal
|
||||
|
@ -95,25 +93,6 @@
|
|||
this.setupLeftPane();
|
||||
}
|
||||
|
||||
const inboxCollection = getInboxCollection();
|
||||
|
||||
this.listenTo(inboxCollection, 'messageError', () => {
|
||||
if (this.networkStatusView) {
|
||||
this.networkStatusView.update();
|
||||
}
|
||||
});
|
||||
|
||||
this.networkStatusView = new Whisper.NetworkStatusView();
|
||||
this.$el
|
||||
.find('.network-status-container')
|
||||
.append(this.networkStatusView.render().el);
|
||||
|
||||
if (extension.expired()) {
|
||||
const banner = new Whisper.ExpiredAlertBanner().render();
|
||||
banner.$el.prependTo(this.$el);
|
||||
this.$el.addClass('expired');
|
||||
}
|
||||
|
||||
Whisper.events.on('pack-install-failed', () => {
|
||||
const toast = new Whisper.StickerPackInstallFailedToast();
|
||||
toast.$el.appendTo(this.$el);
|
||||
|
@ -225,15 +204,4 @@
|
|||
this.closeRecording(e);
|
||||
},
|
||||
});
|
||||
|
||||
Whisper.ExpiredAlertBanner = Whisper.View.extend({
|
||||
templateName: 'expired_alert',
|
||||
className: 'expiredAlert clearfix',
|
||||
render_attributes() {
|
||||
return {
|
||||
expiredWarning: i18n('expiredWarning'),
|
||||
upgrade: i18n('upgrade'),
|
||||
};
|
||||
},
|
||||
});
|
||||
})();
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
// Keep data around if it's a re-link, or the middle of a light import
|
||||
this.shouldRetainData =
|
||||
Whisper.Registration.everDone() || options.hasExistingData;
|
||||
window.Signal.Util.Registration.everDone() || options.hasExistingData;
|
||||
},
|
||||
render_attributes() {
|
||||
let errorMessage;
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
/* global Whisper, extension, Backbone, moment, i18n */
|
||||
|
||||
// eslint-disable-next-line func-names
|
||||
(function() {
|
||||
'use strict';
|
||||
|
||||
window.Whisper = window.Whisper || {};
|
||||
|
||||
Whisper.NetworkStatusView = Whisper.View.extend({
|
||||
className: 'network-status',
|
||||
templateName: 'networkStatus',
|
||||
initialize() {
|
||||
this.$el.hide();
|
||||
|
||||
this.renderIntervalHandle = setInterval(this.update.bind(this), 5000);
|
||||
extension.windows.onClosed(() => {
|
||||
clearInterval(this.renderIntervalHandle);
|
||||
});
|
||||
|
||||
setTimeout(this.finishConnectingGracePeriod.bind(this), 5000);
|
||||
|
||||
this.withinConnectingGracePeriod = true;
|
||||
this.setSocketReconnectInterval(null);
|
||||
|
||||
window.addEventListener('online', this.update.bind(this));
|
||||
window.addEventListener('offline', this.update.bind(this));
|
||||
|
||||
this.model = new Backbone.Model();
|
||||
this.listenTo(this.model, 'change', this.onChange);
|
||||
},
|
||||
onReconnectTimer() {
|
||||
this.setSocketReconnectInterval(60000);
|
||||
},
|
||||
finishConnectingGracePeriod() {
|
||||
this.withinConnectingGracePeriod = false;
|
||||
},
|
||||
setSocketReconnectInterval(millis) {
|
||||
this.socketReconnectWaitDuration = moment.duration(millis);
|
||||
},
|
||||
navigatorOnLine() {
|
||||
return navigator.onLine;
|
||||
},
|
||||
getSocketStatus() {
|
||||
return window.getSocketStatus();
|
||||
},
|
||||
getNetworkStatus() {
|
||||
let message = '';
|
||||
let instructions = '';
|
||||
let hasInterruption = false;
|
||||
let action = null;
|
||||
let buttonClass = null;
|
||||
|
||||
const socketStatus = this.getSocketStatus();
|
||||
switch (socketStatus) {
|
||||
case WebSocket.CONNECTING:
|
||||
message = i18n('connecting');
|
||||
this.setSocketReconnectInterval(null);
|
||||
break;
|
||||
case WebSocket.OPEN:
|
||||
this.setSocketReconnectInterval(null);
|
||||
break;
|
||||
case WebSocket.CLOSED:
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
break;
|
||||
case WebSocket.CLOSING:
|
||||
default:
|
||||
message = i18n('disconnected');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
hasInterruption = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (
|
||||
socketStatus === WebSocket.CONNECTING &&
|
||||
!this.withinConnectingGracePeriod
|
||||
) {
|
||||
hasInterruption = true;
|
||||
}
|
||||
if (this.socketReconnectWaitDuration.asSeconds() > 0) {
|
||||
instructions = i18n('attemptingReconnection', [
|
||||
this.socketReconnectWaitDuration.asSeconds(),
|
||||
]);
|
||||
}
|
||||
if (!this.navigatorOnLine()) {
|
||||
hasInterruption = true;
|
||||
message = i18n('offline');
|
||||
instructions = i18n('checkNetworkConnection');
|
||||
} else if (!Whisper.Registration.isDone()) {
|
||||
hasInterruption = true;
|
||||
message = i18n('unlinked');
|
||||
instructions = i18n('unlinkedWarning');
|
||||
action = i18n('relink');
|
||||
buttonClass = 'openInstaller';
|
||||
}
|
||||
|
||||
return {
|
||||
message,
|
||||
instructions,
|
||||
hasInterruption,
|
||||
action,
|
||||
buttonClass,
|
||||
};
|
||||
},
|
||||
update() {
|
||||
const status = this.getNetworkStatus();
|
||||
this.model.set(status);
|
||||
},
|
||||
render_attributes() {
|
||||
return this.model.attributes;
|
||||
},
|
||||
onChange() {
|
||||
this.render();
|
||||
if (this.model.attributes.hasInterruption) {
|
||||
this.$el.slideDown();
|
||||
} else {
|
||||
this.$el.hide();
|
||||
}
|
||||
},
|
||||
});
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue