@@ -27,7 +27,8 @@ import AccessibleButton from '../views/elements/AccessibleButton';
27
27
import Modal from '../../Modal' ;
28
28
import classnames from 'classnames' ;
29
29
30
- import GroupSummaryStore from '../../stores/GroupSummaryStore' ;
30
+ import GroupStoreCache from '../../stores/GroupStoreCache' ;
31
+ import GroupStore from '../../stores/GroupStore' ;
31
32
32
33
const RoomSummaryType = PropTypes . shape ( {
33
34
room_id : PropTypes . string . isRequired ,
@@ -78,7 +79,7 @@ const CategoryRoomList = React.createClass({
78
79
if ( ! success ) return ;
79
80
const errorList = [ ] ;
80
81
Promise . all ( addrs . map ( ( addr ) => {
81
- return this . context . groupSummaryStore
82
+ return this . context . groupStore
82
83
. addRoomToGroupSummary ( addr . address )
83
84
. catch ( ( ) => { errorList . push ( addr . address ) ; } )
84
85
. reflect ( ) ;
@@ -157,7 +158,7 @@ const FeaturedRoom = React.createClass({
157
158
onDeleteClicked : function ( e ) {
158
159
e . preventDefault ( ) ;
159
160
e . stopPropagation ( ) ;
160
- this . context . groupSummaryStore . removeRoomFromGroupSummary (
161
+ this . context . groupStore . removeRoomFromGroupSummary (
161
162
this . props . summaryInfo . room_id ,
162
163
) . catch ( ( err ) => {
163
164
console . error ( 'Error whilst removing room from group summary' , err ) ;
@@ -252,7 +253,7 @@ const RoleUserList = React.createClass({
252
253
if ( ! success ) return ;
253
254
const errorList = [ ] ;
254
255
Promise . all ( addrs . map ( ( addr ) => {
255
- return this . context . groupSummaryStore
256
+ return this . context . groupStore
256
257
. addUserToGroupSummary ( addr . address )
257
258
. catch ( ( ) => { errorList . push ( addr . address ) ; } )
258
259
. reflect ( ) ;
@@ -327,7 +328,7 @@ const FeaturedUser = React.createClass({
327
328
onDeleteClicked : function ( e ) {
328
329
e . preventDefault ( ) ;
329
330
e . stopPropagation ( ) ;
330
- this . context . groupSummaryStore . removeUserFromGroupSummary (
331
+ this . context . groupStore . removeUserFromGroupSummary (
331
332
this . props . summaryInfo . user_id ,
332
333
) . catch ( ( err ) => {
333
334
console . error ( 'Error whilst removing user from group summary' , err ) ;
@@ -373,14 +374,14 @@ const FeaturedUser = React.createClass({
373
374
} ,
374
375
} ) ;
375
376
376
- const GroupSummaryContext = {
377
- groupSummaryStore : React . PropTypes . instanceOf ( GroupSummaryStore ) . isRequired ,
377
+ const GroupContext = {
378
+ groupStore : React . PropTypes . instanceOf ( GroupStore ) . isRequired ,
378
379
} ;
379
380
380
- CategoryRoomList . contextTypes = GroupSummaryContext ;
381
- FeaturedRoom . contextTypes = GroupSummaryContext ;
382
- RoleUserList . contextTypes = GroupSummaryContext ;
383
- FeaturedUser . contextTypes = GroupSummaryContext ;
381
+ CategoryRoomList . contextTypes = GroupContext ;
382
+ FeaturedRoom . contextTypes = GroupContext ;
383
+ RoleUserList . contextTypes = GroupContext ;
384
+ FeaturedUser . contextTypes = GroupContext ;
384
385
385
386
export default React . createClass ( {
386
387
displayName : 'GroupView' ,
@@ -390,12 +391,12 @@ export default React.createClass({
390
391
} ,
391
392
392
393
childContextTypes : {
393
- groupSummaryStore : React . PropTypes . instanceOf ( GroupSummaryStore ) ,
394
+ groupStore : React . PropTypes . instanceOf ( GroupStore ) ,
394
395
} ,
395
396
396
397
getChildContext : function ( ) {
397
398
return {
398
- groupSummaryStore : this . _groupSummaryStore ,
399
+ groupStore : this . _groupStore ,
399
400
} ;
400
401
} ,
401
402
@@ -413,14 +414,14 @@ export default React.createClass({
413
414
414
415
componentWillMount : function ( ) {
415
416
this . _changeAvatarComponent = null ;
416
- this . _initGroupSummaryStore ( this . props . groupId ) ;
417
+ this . _initGroupStore ( this . props . groupId ) ;
417
418
418
419
MatrixClientPeg . get ( ) . on ( "Group.myMembership" , this . _onGroupMyMembership ) ;
419
420
} ,
420
421
421
422
componentWillUnmount : function ( ) {
422
423
MatrixClientPeg . get ( ) . removeListener ( "Group.myMembership" , this . _onGroupMyMembership ) ;
423
- this . _groupSummaryStore . removeAllListeners ( ) ;
424
+ this . _groupStore . removeAllListeners ( ) ;
424
425
} ,
425
426
426
427
componentWillReceiveProps : function ( newProps ) {
@@ -429,7 +430,7 @@ export default React.createClass({
429
430
summary : null ,
430
431
error : null ,
431
432
} , ( ) => {
432
- this . _initGroupSummaryStore ( newProps . groupId ) ;
433
+ this . _initGroupStore ( newProps . groupId ) ;
433
434
} ) ;
434
435
}
435
436
} ,
@@ -440,17 +441,15 @@ export default React.createClass({
440
441
this . setState ( { membershipBusy : false } ) ;
441
442
} ,
442
443
443
- _initGroupSummaryStore : function ( groupId ) {
444
- this . _groupSummaryStore = new GroupSummaryStore (
445
- MatrixClientPeg . get ( ) , this . props . groupId ,
446
- ) ;
447
- this . _groupSummaryStore . on ( 'update' , ( ) => {
444
+ _initGroupStore : function ( groupId ) {
445
+ this . _groupStore = GroupStoreCache . getGroupStore ( MatrixClientPeg . get ( ) , groupId ) ;
446
+ this . _groupStore . on ( 'update' , ( ) => {
448
447
this . setState ( {
449
- summary : this . _groupSummaryStore . getSummary ( ) ,
448
+ summary : this . _groupStore . getSummary ( ) ,
450
449
error : null ,
451
450
} ) ;
452
451
} ) ;
453
- this . _groupSummaryStore . on ( 'error' , ( err ) => {
452
+ this . _groupStore . on ( 'error' , ( err ) => {
454
453
this . setState ( {
455
454
summary : null ,
456
455
error : err ,
@@ -527,7 +526,7 @@ export default React.createClass({
527
526
editing : false ,
528
527
summary : null ,
529
528
} ) ;
530
- this . _initGroupSummaryStore ( this . props . groupId ) ;
529
+ this . _initGroupStore ( this . props . groupId ) ;
531
530
} ) . catch ( ( e ) => {
532
531
this . setState ( {
533
532
saving : false ,
@@ -606,7 +605,7 @@ export default React.createClass({
606
605
this . setState ( {
607
606
publicityBusy : true ,
608
607
} ) ;
609
- this . _groupSummaryStore . setGroupPublicity ( publicity ) . then ( ( ) => {
608
+ this . _groupStore . setGroupPublicity ( publicity ) . then ( ( ) => {
610
609
this . setState ( {
611
610
publicityBusy : false ,
612
611
} ) ;
0 commit comments