AppView: Store initialLoadComplete value for late openInbox
FREEBIE
This commit is contained in:
parent
082919abd1
commit
ac237b9e31
1 changed files with 18 additions and 3 deletions
|
@ -79,14 +79,27 @@
|
||||||
},
|
},
|
||||||
openInbox: function(options) {
|
openInbox: function(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
_.defaults(options, {initialLoadComplete: false});
|
// The inbox can be created before the 'empty' event fires or afterwards. If
|
||||||
|
// before, it's straightforward: the onEmpty() handler below updates the
|
||||||
|
// view directly, and we're in good shape. If we create the inbox late, we
|
||||||
|
// need to be sure that the current value of initialLoadComplete is provided
|
||||||
|
// so its loading screen doesn't stick around forever.
|
||||||
|
|
||||||
|
// Two primary techniques at play for this situation:
|
||||||
|
// - background.js has two openInbox() calls, and passes initalLoadComplete
|
||||||
|
// directly via the options parameter.
|
||||||
|
// - in other situations openInbox() will be called with no options. So this
|
||||||
|
// view keeps track of whether onEmpty() has ever been called with
|
||||||
|
// this.initialLoadComplete. An example of this: on a phone-pairing setup.
|
||||||
|
_.defaults(options, {initialLoadComplete: this.initialLoadComplete});
|
||||||
|
|
||||||
console.log('open inbox');
|
console.log('open inbox');
|
||||||
this.closeInstaller();
|
this.closeInstaller();
|
||||||
|
|
||||||
if (!this.inboxView) {
|
if (!this.inboxView) {
|
||||||
// We create the inbox immediately to make sure we're ready to receive the
|
// We create the inbox immediately so we don't miss an update to
|
||||||
// empty event after getting down to zero messages in the queue.
|
// this.initialLoadComplete between the start of this method and the
|
||||||
|
// creation of inboxView.
|
||||||
this.inboxView = new Whisper.InboxView({
|
this.inboxView = new Whisper.InboxView({
|
||||||
model: self,
|
model: self,
|
||||||
window: window,
|
window: window,
|
||||||
|
@ -105,6 +118,8 @@
|
||||||
},
|
},
|
||||||
onEmpty: function() {
|
onEmpty: function() {
|
||||||
var view = this.inboxView;
|
var view = this.inboxView;
|
||||||
|
|
||||||
|
this.initialLoadComplete = true;
|
||||||
if (view) {
|
if (view) {
|
||||||
view.onEmpty();
|
view.onEmpty();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue