@@ -587,7 +587,7 @@ module.exports = baseVw.extend({
587587 toggleModeratorButtons : function ( moderated ) {
588588 var addBtn = this . $ ( '.js-addmoderator' ) ,
589589 removeBtn = this . $ ( '.js-removemoderator' ) ;
590- if ( moderated === true ) {
590+ if ( moderated == true ) {
591591 addBtn . addClass ( 'hide' ) ;
592592 removeBtn . removeClass ( 'hide' ) ;
593593 } else {
@@ -1442,26 +1442,15 @@ module.exports = baseVw.extend({
14421442
14431443 $targ . addClass ( 'loading' ) ;
14441444
1445- var user = this . model . get ( 'user' ) ;
14461445 var self = this ;
14471446
14481447 var modList = { } ;
1449- modList . moderators = user . moderators ;
1450- modList . moderators [ modList . moderators . length ] = this . userProfile . get ( 'profile' ) . guid ;
1451- user . moderators = modList . moderators ;
1448+ modList . moderators = this . model . get ( 'user' ) . moderators ;
1449+ modList . moderators . push ( this . pageID ) ;
14521450
1453- saveToAPI ( '' , user , user . serverUrl + "settings" ,
1451+ saveToAPI ( '' , this . model . get ( ' user' ) , this . model . get ( ' user' ) . serverUrl + "settings" ,
14541452 function ( ) {
14551453 // confirmed
1456- $targ . removeClass ( 'loading' ) ;
1457- } ,
1458- function ( ) {
1459- // failed
1460- } , modList , '' ,
1461- function ( ) {
1462- // invalid
1463- } ) . always ( function ( ) {
1464- $targ . removeClass ( 'loading' ) ;
14651454 self . options . userModel . fetch ( {
14661455 success : function ( model , response ) {
14671456 if ( self . isRemoved ( ) ) return ;
@@ -1471,6 +1460,8 @@ module.exports = baseVw.extend({
14711460 self . getIsModerator ( ) ;
14721461 }
14731462 } ) ;
1463+ } , '' , modList , '' , '' ) . always ( function ( ) {
1464+ $targ . removeClass ( 'loading' ) ;
14741465 } ) ;
14751466 } ,
14761467
@@ -1480,43 +1471,32 @@ module.exports = baseVw.extend({
14801471 if ( $targ . hasClass ( 'confirm' ) ) {
14811472 $targ . addClass ( 'loading' ) . removeClass ( 'confirm' ) ;
14821473
1483-
1484- var user = this . model . get ( 'user' ) ;
14851474 var self = this ;
14861475
14871476 var modList = { } ;
14881477 modList . moderators = [ ] ;
1489- var guid = this . userProfile . get ( 'profile' ) . guid ;
14901478
1491- __ . each ( user . moderators , function ( mod ) {
1492- if ( mod != guid && ( typeof ( mod ) !== 'object' || mod . guid != guid ) ) {
1493- modList . moderators [ modList . moderators . length ] = mod ;
1479+ __ . each ( this . model . get ( ' user' ) . moderators , function ( mod ) {
1480+ if ( mod != guid && ( typeof ( mod ) !== 'object' || mod . guid != this . pageID ) ) {
1481+ modList . moderators . push ( mod ) ;
14941482 }
14951483 } )
1496- user . moderators = modList . moderators ;
14971484
1498- saveToAPI ( '' , user , user . serverUrl + "settings" ,
1499- function ( ) {
1500- // confirmed
1501- $targ . removeClass ( 'loading' ) ;
1502- } ,
1503- function ( ) {
1504- // failed
1505- } , modList , '' ,
1506- function ( ) {
1507- // invalid
1508- } ) . always ( function ( ) {
1509- $targ . removeClass ( 'loading' ) ;
1510- self . options . userModel . fetch ( {
1511- success : function ( model , response ) {
1512- if ( self . isRemoved ( ) ) return ;
1513- var user = self . model . get ( 'user' ) ;
1514- user . moderators = model . get ( 'moderators' ) ;
1515- user . moderator_guids = model . get ( 'moderator_guids' ) ;
1516- self . getIsModerator ( ) ;
1517- }
1518- } ) ;
1485+ saveToAPI ( '' , this . model . get ( 'user' ) , this . model . get ( 'user' ) . serverUrl + "settings" ,
1486+ function ( ) {
1487+ // confirmed
1488+ self . options . userModel . fetch ( {
1489+ success : function ( model , response ) {
1490+ if ( self . isRemoved ( ) ) return ;
1491+ var user = self . model . get ( 'user' ) ;
1492+ user . moderators = model . get ( 'moderators' ) ;
1493+ user . moderator_guids = model . get ( 'moderator_guids' ) ;
1494+ self . getIsModerator ( ) ;
1495+ }
15191496 } ) ;
1497+ } , '' , modList , '' , '' ) . always ( function ( ) {
1498+ $targ . removeClass ( 'loading' ) ;
1499+ } ) ;
15201500 } else {
15211501 $targ . addClass ( 'confirm' ) ;
15221502 }
0 commit comments