diff --git a/js/models/conversations.js b/js/models/conversations.js index 4300ee6f9..c4e03d71a 100644 --- a/js/models/conversations.js +++ b/js/models/conversations.js @@ -636,7 +636,9 @@ }, fetchMessages: function() { - if (!this.id) { return false; } + if (!this.id) { + return Promise.reject('This conversation has no id!'); + } return this.messageCollection.fetchConversation(this.id, null, this.get('unreadCount')); }, diff --git a/js/models/messages.js b/js/models/messages.js index 230e64582..7d831a3ef 100644 --- a/js/models/messages.js +++ b/js/models/messages.js @@ -624,7 +624,7 @@ // SELECT messages WHERE conversationId = this.id ORDER // received_at DESC }; - this.fetch(options).then(resolve); + this.fetch(options).always(resolve); }.bind(this)).then(function() { if (unreadCount > 0) { if (unreadCount <= startingLoadedUnread) { @@ -637,6 +637,7 @@ return; } + console.log('fetchConversation: doing another fetch to get all unread'); return this.fetchConversation(conversationId, limit, unreadCount); } }.bind(this)); diff --git a/js/views/conversation_view.js b/js/views/conversation_view.js index f74c661e5..3e4cb5c43 100644 --- a/js/views/conversation_view.js +++ b/js/views/conversation_view.js @@ -474,8 +474,10 @@ }); this.inProgressFetch = null; }.bind(this)); + }.bind(this)).catch(function(error) { + console.log('fetchMessages error:', error && error.stack ? error.stack : error); + this.inProgressFetch = null; }.bind(this)); - // TODO catch? return this.inProgressFetch; },