A guard to prevent infinite loops in fetching of conversation
FREEBIE
This commit is contained in:
parent
66b19d5cf7
commit
2c81539042
1 changed files with 5 additions and 0 deletions
|
@ -541,6 +541,7 @@
|
||||||
if (typeof unreadCount !== 'number') {
|
if (typeof unreadCount !== 'number') {
|
||||||
unreadCount = 0;
|
unreadCount = 0;
|
||||||
}
|
}
|
||||||
|
var startingLoadedUnread = this.getLoadedUnreadCount();
|
||||||
return new Promise(function(resolve) {
|
return new Promise(function(resolve) {
|
||||||
var upper;
|
var upper;
|
||||||
if (this.length === 0) {
|
if (this.length === 0) {
|
||||||
|
@ -563,6 +564,10 @@
|
||||||
this.fetch(options).then(resolve);
|
this.fetch(options).then(resolve);
|
||||||
}.bind(this)).then(function() {
|
}.bind(this)).then(function() {
|
||||||
var loadedUnread = this.getLoadedUnreadCount();
|
var loadedUnread = this.getLoadedUnreadCount();
|
||||||
|
if (startingLoadedUnread === loadedUnread) {
|
||||||
|
// that fetch didn't get us any more unread. stop fetching more.
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (loadedUnread < unreadCount) {
|
if (loadedUnread < unreadCount) {
|
||||||
return this.fetchConversation(conversationId, limit, unreadCount);
|
return this.fetchConversation(conversationId, limit, unreadCount);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue