@@ -435,14 +435,15 @@ export default React.createClass({
435
435
} ,
436
436
437
437
componentWillMount : function ( ) {
438
+ this . _matrixClient = MatrixClientPeg . get ( ) ;
439
+ this . _matrixClient . on ( "Group.myMembership" , this . _onGroupMyMembership ) ;
440
+
438
441
this . _changeAvatarComponent = null ;
439
442
this . _initGroupStore ( this . props . groupId , true ) ;
440
-
441
- MatrixClientPeg . get ( ) . on ( "Group.myMembership" , this . _onGroupMyMembership ) ;
442
443
} ,
443
444
444
445
componentWillUnmount : function ( ) {
445
- MatrixClientPeg . get ( ) . removeListener ( "Group.myMembership" , this . _onGroupMyMembership ) ;
446
+ this . _matrixClient . removeListener ( "Group.myMembership" , this . _onGroupMyMembership ) ;
446
447
this . _groupStore . removeAllListeners ( ) ;
447
448
} ,
448
449
@@ -464,11 +465,11 @@ export default React.createClass({
464
465
} ,
465
466
466
467
_initGroupStore : function ( groupId , firstInit ) {
467
- const group = MatrixClientPeg . get ( ) . getGroup ( groupId ) ;
468
+ const group = this . _matrixClient . getGroup ( groupId ) ;
468
469
if ( group && group . inviter && group . inviter . userId ) {
469
470
this . _fetchInviterProfile ( group . inviter . userId ) ;
470
471
}
471
- this . _groupStore = GroupStoreCache . getGroupStore ( MatrixClientPeg . get ( ) , groupId ) ;
472
+ this . _groupStore = GroupStoreCache . getGroupStore ( this . _matrixClient , groupId ) ;
472
473
this . _groupStore . registerListener ( ( ) => {
473
474
const summary = this . _groupStore . getSummary ( ) ;
474
475
if ( summary . profile ) {
@@ -486,7 +487,7 @@ export default React.createClass({
486
487
groupRooms : this . _groupStore . getGroupRooms ( ) ,
487
488
groupRoomsLoading : ! this . _groupStore . isStateReady ( GroupStore . STATE_KEY . GroupRooms ) ,
488
489
isUserMember : this . _groupStore . getGroupMembers ( ) . some (
489
- ( m ) => m . userId === MatrixClientPeg . get ( ) . credentials . userId ,
490
+ ( m ) => m . userId === this . _matrixClient . credentials . userId ,
490
491
) ,
491
492
error : null ,
492
493
} ) ;
@@ -506,7 +507,7 @@ export default React.createClass({
506
507
this . setState ( {
507
508
inviterProfileBusy : true ,
508
509
} ) ;
509
- MatrixClientPeg . get ( ) . getProfileInfo ( userId ) . then ( ( resp ) => {
510
+ this . _matrixClient . getProfileInfo ( userId ) . then ( ( resp ) => {
510
511
this . setState ( {
511
512
inviterProfile : {
512
513
avatarUrl : resp . avatar_url ,
@@ -571,7 +572,7 @@ export default React.createClass({
571
572
if ( ! file ) return ;
572
573
573
574
this . setState ( { uploadingAvatar : true } ) ;
574
- MatrixClientPeg . get ( ) . uploadContent ( file ) . then ( ( url ) => {
575
+ this . _matrixClient . uploadContent ( file ) . then ( ( url ) => {
575
576
const newProfileForm = Object . assign ( this . state . profileForm , { avatar_url : url } ) ;
576
577
this . setState ( {
577
578
uploadingAvatar : false ,
@@ -591,7 +592,7 @@ export default React.createClass({
591
592
_onSaveClick : function ( ) {
592
593
this . setState ( { saving : true } ) ;
593
594
const savePromise = this . state . isUserPrivileged ?
594
- MatrixClientPeg . get ( ) . setGroupProfile ( this . props . groupId , this . state . profileForm ) :
595
+ this . _matrixClient . setGroupProfile ( this . props . groupId , this . state . profileForm ) :
595
596
Promise . resolve ( ) ;
596
597
savePromise . then ( ( result ) => {
597
598
this . setState ( {
@@ -630,7 +631,7 @@ export default React.createClass({
630
631
631
632
_onRejectInviteClick : function ( ) {
632
633
this . setState ( { membershipBusy : true } ) ;
633
- MatrixClientPeg . get ( ) . leaveGroup ( this . props . groupId ) . then ( ( ) => {
634
+ this . _matrixClient . leaveGroup ( this . props . groupId ) . then ( ( ) => {
634
635
// don't reset membershipBusy here: wait for the membership change to come down the sync
635
636
} ) . catch ( ( e ) => {
636
637
this . setState ( { membershipBusy : false } ) ;
@@ -653,7 +654,7 @@ export default React.createClass({
653
654
if ( ! confirmed ) return ;
654
655
655
656
this . setState ( { membershipBusy : true } ) ;
656
- MatrixClientPeg . get ( ) . leaveGroup ( this . props . groupId ) . then ( ( ) => {
657
+ this . _matrixClient . leaveGroup ( this . props . groupId ) . then ( ( ) => {
657
658
// don't reset membershipBusy here: wait for the membership change to come down the sync
658
659
} ) . catch ( ( e ) => {
659
660
this . setState ( { membershipBusy : false } ) ;
@@ -829,7 +830,7 @@ export default React.createClass({
829
830
const Spinner = sdk . getComponent ( "elements.Spinner" ) ;
830
831
const BaseAvatar = sdk . getComponent ( "avatars.BaseAvatar" ) ;
831
832
832
- const group = MatrixClientPeg . get ( ) . getGroup ( this . props . groupId ) ;
833
+ const group = this . _matrixClient . getGroup ( this . props . groupId ) ;
833
834
if ( ! group ) return null ;
834
835
835
836
if ( group . myMembership === 'invite' ) {
@@ -839,7 +840,7 @@ export default React.createClass({
839
840
</ div > ;
840
841
}
841
842
const httpInviterAvatar = this . state . inviterProfile ?
842
- MatrixClientPeg . get ( ) . mxcUrlToHttp (
843
+ this . _matrixClient . mxcUrlToHttp (
843
844
this . state . inviterProfile . avatarUrl , 36 , 36 ,
844
845
) : null ;
845
846
0 commit comments