Skip to content
This repository was archived by the owner on May 16, 2019. It is now read-only.

Commit ffe0065

Browse files
committed
Merge pull request #1494 from OpenBazaar/fixLongFollowerLists
prevent too many calls to get_followers
2 parents 5f3aec0 + 616e0f8 commit ffe0065

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

js/views/userListVw.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ module.exports = Backbone.View.extend({
2525
this.usersShort = new usersShortCollection(this.model);
2626
this.options.reverse && this.usersShort.models.reverse();
2727
this.subViews = [];
28-
this.showPerScroll = 10;
29-
this.fetchMoreAfter = options.perFetch;
28+
this.showPerScroll = 30;
3029
this.nextUserToShow = 0;
3130
this.fetchedUsers = this.usersShort.length;
3231
this.totalUsers = this.options.followerCount;
@@ -81,8 +80,7 @@ module.exports = Backbone.View.extend({
8180

8281
this.nextUserToShow = this.nextUserToShow >= this.fetchedUsers ? this.nextUserToShow : this.nextUserToShow + this.showPerScroll;
8382

84-
if(this.fetchMoreAfter && end == this.fetchMoreAfter && this.fetchedUsers < this.totalUsers){
85-
this.fetchMoreAfter = this.fetchMoreAfter + this.options.perFetch;
83+
if(this.fetchedUsers < this.totalUsers && this.$el.is(':visible')){
8684
this.trigger('fetchMoreUsers');
8785
}
8886
},

js/views/userPageVw.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,13 @@ module.exports = baseVw.extend({
700700
//don't fetch again if all of the followers have been fetched
701701
return;
702702
}
703+
704+
if(this.fetchingFollowers){
705+
//don't cue up multiple calls
706+
return;
707+
}
708+
709+
this.fetchingFollowers = true;
703710

704711
if(this.options.ownPage){
705712
fetchFollowersParameters = $.param({'start': this.followerFetchStart});
@@ -727,6 +734,7 @@ module.exports = baseVw.extend({
727734
messageModal.show(window.polyglot.t('errorMessages.notFoundError'), window.polyglot.t('Followers'));
728735
},
729736
complete: function(xhr, textStatus) {
737+
self.fetchingFollowers = false;
730738
if(textStatus == 'parsererror'){
731739
messageModal.show(window.polyglot.t('errorMessages.serverError'), window.polyglot.t('errorMessages.badJSON'));
732740
throw new Error("The followers data returned from the API has a parsing error.");

0 commit comments

Comments
 (0)