From fc3924100395621e5fabe0348f05377ece5c84b9 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 15 Jun 2017 18:23:29 -0700 Subject: [PATCH] Ensure that we pull verified state only after getting profiles FREEBIE --- js/models/conversations.js | 2 +- js/views/conversation_view.js | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/js/models/conversations.js b/js/models/conversations.js index 71bea46fd..cad6c4003 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -559,7 +559,7 @@ } else { ids = this.get('members'); } - ids.forEach(this.getProfile); + return Promise.all(_.map(ids, this.getProfile)); }, getProfile: function(id) { diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index dc4f25e30..207083c8c 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -306,21 +306,22 @@ }, onOpened: function() { - this.model.getProfiles(); + // TODO: we may want to show a loading dialog until this status fetch + // and potentially the below message fetch are complete. In the near + // term, just a send block if this statusFetch is incomplete might be + // a good idea. + this.statusFetch = this.model.getProfiles().then(function() { + this.model.updateVerified().then(function() { + this.onVerifiedChange.bind(this); + this.statusFetch = null; + console.log('done with status fetch'); + }.bind(this)); + }.bind(this)); this.view.resetScrollPosition(); this.$el.trigger('force-resize'); this.focusMessageField(); - // TODO: do a fetch of all profiles to get the latest identity keys, then: - // We have a number of async things happening here: - // 1. we need to get contacts before we do anything with groups - // 2. we need to get profile information for each contact - // 3. we need to get all messages for conversation - // 4. we need to get updated verified information for each contact - // 5. we perhaps need to throw up the banner if in unverified state - this.model.updateVerified().then(this.onVerifiedChange.bind(this)); - if (this.inProgressFetch) { this.inProgressFetch.then(this.updateUnread.bind(this)); } else {