@@ -664,6 +664,10 @@ module.exports = baseVw.extend({
664664 if ( self . options . ownPage === false && Boolean ( __ . findWhere ( followingArray , { guid : self . userID } ) ) ) {
665665 self . $ ( '.js-followsMe' ) . removeClass ( 'hide' )
666666 }
667+ //mark whether page is being followed
668+ if ( self . options . ownPage === false ) {
669+ self . toggleFollowButtons ( Boolean ( __ . findWhere ( followingArray , { guid : self . pageID } ) ) ) ;
670+ }
667671
668672 } ) . fail ( function ( jqXHR , status , errorThrown ) {
669673 if ( self . isRemoved ( ) ) return ;
@@ -690,27 +694,26 @@ module.exports = baseVw.extend({
690694 var self = this ,
691695 fetchFollowersParameters ;
692696
693- if ( this . ownPage ) {
697+ if ( this . options . ownPage ) {
694698 fetchFollowersParameters = $ . param ( { 'start' : this . followerFetchStart } ) ;
695699 } else {
696700 fetchFollowersParameters = $ . param ( { 'guid' : this . pageID , 'start' : this . followerFetchStart } ) ;
697701 }
698702
703+ console . log ( "fetchFollowers" )
704+
699705 this . followers . fetch ( {
700- data : self . userProfileFetchParameters ,
706+ data : fetchFollowersParameters ,
701707 //timeout: 5000,
702708 success : ( model ) => {
703- var followerArray = model . get ( 'followers' ) ;
704- this . $ ( '.js-userFollowerCount' ) . html ( model . get ( 'count' ) ) ;
705- this . followerFetchStart += model . length ;
709+ var followerArray = model . get ( 'followers' ) ,
710+ followerCount = model . get ( 'count' ) || followerArray . length ;
711+ this . $ ( '.js-userFollowerCount' ) . html ( followerCount ) ;
712+ this . followerFetchStart += followerArray . length ;
706713
707714 if ( self . isRemoved ( ) ) return ;
708715
709- this . renderFollowers ( followerArray ) ;
710- //if this is not their page, see if they are being followed
711- if ( this . options . ownPage === false ) {
712- this . toggleFollowButtons ( Boolean ( __ . findWhere ( followerArray , { guid : this . userID } ) ) ) ;
713- }
716+ this . renderFollowers ( followerArray , followerCount ) ;
714717 } ,
715718 error : function ( model , response ) {
716719 if ( self . isRemoved ( ) ) return ;
@@ -793,22 +796,27 @@ module.exports = baseVw.extend({
793796 }
794797 } ,
795798
796- renderFollowers : function ( model ) {
799+ renderFollowers : function ( model , followerCount ) {
797800 "use strict" ;
798801
799802 model = model || [ ] ;
800- this . followerList = new personListView ( {
801- model : model ,
802- el : '.js-list1' ,
803- title : window . polyglot . t ( 'NoFollowers' ) ,
804- message : "" ,
805- ownFollowing : this . ownFollowing ,
806- hideFollow : true ,
807- serverUrl : this . options . userModel . get ( 'serverUrl' ) ,
808- reverse : true ,
809- perFetch : 30
810- } ) ;
811- this . registerChild ( this . followerList ) ;
803+ if ( ! this . followerList ) {
804+ this . followerList = new personListView ( {
805+ model : model ,
806+ el : '.js-list1' ,
807+ title : window . polyglot . t ( 'NoFollowers' ) ,
808+ message : "" ,
809+ ownFollowing : this . ownFollowing ,
810+ hideFollow : true ,
811+ serverUrl : this . options . userModel . get ( 'serverUrl' ) ,
812+ reverse : true ,
813+ perFetch : 30 ,
814+ followerCount : followerCount
815+ } ) ;
816+ this . registerChild ( this . followerList ) ;
817+ } else {
818+ this . followerList . addUsers ( model ) ;
819+ }
812820
813821 if ( model . length ) {
814822 this . followersSearch = new window . List ( 'searchFollowers' , {
@@ -822,6 +830,11 @@ module.exports = baseVw.extend({
822830 this . followersSearch . reIndex ( ) ;
823831 searchTerms && this . followersSearch . search ( searchTerms ) ;
824832 } ) ;
833+
834+ this . listenTo ( this . followerList , 'fetchMoreUsers' , ( ) => {
835+ console . log ( "trigger fetch" ) ;
836+ this . fetchFollowers ( ) ;
837+ } ) ;
825838 } ,
826839
827840 renderFollowing : function ( model ) {
0 commit comments