Ensure that promises always resolve, or that rejections are okay
This commit is contained in:
parent
4da1722ee8
commit
e6859a3684
3 changed files with 8 additions and 3 deletions
|
@ -636,7 +636,9 @@
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchMessages: function() {
|
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'));
|
return this.messageCollection.fetchConversation(this.id, null, this.get('unreadCount'));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -624,7 +624,7 @@
|
||||||
// SELECT messages WHERE conversationId = this.id ORDER
|
// SELECT messages WHERE conversationId = this.id ORDER
|
||||||
// received_at DESC
|
// received_at DESC
|
||||||
};
|
};
|
||||||
this.fetch(options).then(resolve);
|
this.fetch(options).always(resolve);
|
||||||
}.bind(this)).then(function() {
|
}.bind(this)).then(function() {
|
||||||
if (unreadCount > 0) {
|
if (unreadCount > 0) {
|
||||||
if (unreadCount <= startingLoadedUnread) {
|
if (unreadCount <= startingLoadedUnread) {
|
||||||
|
@ -637,6 +637,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('fetchConversation: doing another fetch to get all unread');
|
||||||
return this.fetchConversation(conversationId, limit, unreadCount);
|
return this.fetchConversation(conversationId, limit, unreadCount);
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
|
@ -474,8 +474,10 @@
|
||||||
});
|
});
|
||||||
this.inProgressFetch = null;
|
this.inProgressFetch = null;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
}.bind(this)).catch(function(error) {
|
||||||
|
console.log('fetchMessages error:', error && error.stack ? error.stack : error);
|
||||||
|
this.inProgressFetch = null;
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
// TODO catch?
|
|
||||||
|
|
||||||
return this.inProgressFetch;
|
return this.inProgressFetch;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue