@@ -184,6 +184,8 @@ module.exports = baseVw.extend({
184184 this . userID = options . userModel . get ( 'guid' ) ;
185185 this . userProfileFetchParameters = { } ;
186186 this . followerFetchStart = 0 ;
187+ this . followersFetchPer = 30 ;
188+ this . followerFetchTotal = 0 ;
187189 this . itemFetchParameters = { } ;
188190 this . model = new Backbone . Model ( ) ;
189191 this . globalUserProfile = options . userProfile ;
@@ -690,30 +692,33 @@ module.exports = baseVw.extend({
690692 } ) ;
691693 } ,
692694
693- fetchFollowers : function ( ) {
695+ fetchFollowers : function ( ignoreTotal ) {
694696 var self = this ,
695697 fetchFollowersParameters ;
696698
699+ if ( ! ignoreTotal && this . followerFetchStart > 0 && this . followerFetchStart >= this . followerFetchTotal ) {
700+ return ;
701+ }
702+
697703 if ( this . options . ownPage ) {
698704 fetchFollowersParameters = $ . param ( { 'start' : this . followerFetchStart } ) ;
699705 } else {
700706 fetchFollowersParameters = $ . param ( { 'guid' : this . pageID , 'start' : this . followerFetchStart } ) ;
701707 }
702-
703- console . log ( "fetchFollowers" )
704-
708+
705709 this . followers . fetch ( {
706710 data : fetchFollowersParameters ,
707711 //timeout: 5000,
708712 success : ( model ) => {
709- var followerArray = model . get ( 'followers' ) ,
710- followerCount = model . get ( 'count' ) || followerArray . length ;
711- this . $ ( '.js-userFollowerCount' ) . html ( followerCount ) ;
712- this . followerFetchStart += followerArray . length ;
713+ var followerArray = model . get ( 'followers' ) ;
714+ this . followerFetchTotal = model . get ( 'count' ) || followerArray . length ;
715+ this . $ ( '.js-userFollowerCount' ) . html ( this . followerFetchTotal ) ;
713716
714717 if ( self . isRemoved ( ) ) return ;
715-
716- this . renderFollowers ( followerArray , followerCount ) ;
718+
719+ if ( followerArray . length ) {
720+ this . renderFollowers ( followerArray , this . followerFetchTotal ) ;
721+ }
717722 } ,
718723 error : function ( model , response ) {
719724 if ( self . isRemoved ( ) ) return ;
@@ -726,6 +731,7 @@ module.exports = baseVw.extend({
726731 }
727732 }
728733 } ) ;
734+ this . followerFetchStart += this . followersFetchPer ;
729735 } ,
730736
731737 getIsModerator : function ( ) {
@@ -814,7 +820,7 @@ module.exports = baseVw.extend({
814820 followerCount : followerCount
815821 } ) ;
816822 this . registerChild ( this . followerList ) ;
817- } else {
823+ } else if ( model . length ) {
818824 this . followerList . addUsers ( model ) ;
819825 }
820826
@@ -832,7 +838,6 @@ module.exports = baseVw.extend({
832838 } ) ;
833839
834840 this . listenTo ( this . followerList , 'fetchMoreUsers' , ( ) => {
835- console . log ( "trigger fetch" ) ;
836841 this . fetchFollowers ( ) ;
837842 } ) ;
838843 } ,
0 commit comments