@@ -144,13 +144,16 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
144
144
// The following properties are set by onReady as they live in account_data
145
145
private _allRoomsInHome = false ;
146
146
private _enabledMetaSpaces : MetaSpace [ ] = [ ] ;
147
+ /** Whether the feature flag is set for MSC3946 */
148
+ private _msc3946ProcessDynamicPredecessor : boolean = SettingsStore . getValue ( "feature_dynamic_room_predecessors" ) ;
147
149
148
150
public constructor ( ) {
149
151
super ( defaultDispatcher , { } ) ;
150
152
151
153
SettingsStore . monitorSetting ( "Spaces.allRoomsInHome" , null ) ;
152
154
SettingsStore . monitorSetting ( "Spaces.enabledMetaSpaces" , null ) ;
153
155
SettingsStore . monitorSetting ( "Spaces.showPeopleInSpace" , null ) ;
156
+ SettingsStore . monitorSetting ( "feature_dynamic_room_predecessors" , null ) ;
154
157
}
155
158
156
159
public get invitedSpaces ( ) : Room [ ] {
@@ -352,7 +355,11 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
352
355
return getChildOrder ( ev . getContent ( ) . order , ev . getTs ( ) , ev . getStateKey ( ) ! ) ;
353
356
} )
354
357
. map ( ( ev ) => {
355
- const history = this . matrixClient . getRoomUpgradeHistory ( ev . getStateKey ( ) ! , true ) ;
358
+ const history = this . matrixClient . getRoomUpgradeHistory (
359
+ ev . getStateKey ( ) ! ,
360
+ true ,
361
+ this . _msc3946ProcessDynamicPredecessor ,
362
+ ) ;
356
363
return history [ history . length - 1 ] ;
357
364
} )
358
365
. filter ( ( room ) => {
@@ -450,7 +457,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
450
457
useCache = true ,
451
458
) : Set < string > => {
452
459
if ( space === MetaSpace . Home && this . allRoomsInHome ) {
453
- return new Set ( this . matrixClient . getVisibleRooms ( ) . map ( ( r ) => r . roomId ) ) ;
460
+ return new Set (
461
+ this . matrixClient . getVisibleRooms ( this . _msc3946ProcessDynamicPredecessor ) . map ( ( r ) => r . roomId ) ,
462
+ ) ;
454
463
}
455
464
456
465
// meta spaces never have descendants
@@ -539,7 +548,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
539
548
} ;
540
549
541
550
private rebuildSpaceHierarchy = ( ) : void => {
542
- const visibleSpaces = this . matrixClient . getVisibleRooms ( ) . filter ( ( r ) => r . isSpaceRoom ( ) ) ;
551
+ const visibleSpaces = this . matrixClient
552
+ . getVisibleRooms ( this . _msc3946ProcessDynamicPredecessor )
553
+ . filter ( ( r ) => r . isSpaceRoom ( ) ) ;
543
554
const [ joinedSpaces , invitedSpaces ] = visibleSpaces . reduce (
544
555
( [ joined , invited ] , s ) => {
545
556
switch ( getEffectiveMembership ( s . getMyMembership ( ) ) ) {
@@ -573,7 +584,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
573
584
} ;
574
585
575
586
private rebuildParentMap = ( ) : void => {
576
- const joinedSpaces = this . matrixClient . getVisibleRooms ( ) . filter ( ( r ) => {
587
+ const joinedSpaces = this . matrixClient . getVisibleRooms ( this . _msc3946ProcessDynamicPredecessor ) . filter ( ( r ) => {
577
588
return r . isSpaceRoom ( ) && r . getMyMembership ( ) === "join" ;
578
589
} ) ;
579
590
@@ -595,7 +606,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
595
606
} else {
596
607
const rooms = new Set (
597
608
this . matrixClient
598
- . getVisibleRooms ( )
609
+ . getVisibleRooms ( this . _msc3946ProcessDynamicPredecessor )
599
610
. filter ( this . showInHomeSpace )
600
611
. map ( ( r ) => r . roomId ) ,
601
612
) ;
@@ -609,7 +620,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
609
620
610
621
private rebuildMetaSpaces = ( ) : void => {
611
622
const enabledMetaSpaces = new Set ( this . enabledMetaSpaces ) ;
612
- const visibleRooms = this . matrixClient . getVisibleRooms ( ) ;
623
+ const visibleRooms = this . matrixClient . getVisibleRooms ( this . _msc3946ProcessDynamicPredecessor ) ;
613
624
614
625
if ( enabledMetaSpaces . has ( MetaSpace . Home ) ) {
615
626
this . rebuildHomeSpace ( ) ;
@@ -643,7 +654,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
643
654
644
655
private updateNotificationStates = ( spaces ?: SpaceKey [ ] ) : void => {
645
656
const enabledMetaSpaces = new Set ( this . enabledMetaSpaces ) ;
646
- const visibleRooms = this . matrixClient . getVisibleRooms ( ) ;
657
+ const visibleRooms = this . matrixClient . getVisibleRooms ( this . _msc3946ProcessDynamicPredecessor ) ;
647
658
648
659
let dmBadgeSpace : MetaSpace | undefined ;
649
660
// only show badges on dms on the most relevant space if such exists
@@ -729,7 +740,7 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
729
740
} ;
730
741
731
742
private onRoomsUpdate = ( ) : void => {
732
- const visibleRooms = this . matrixClient . getVisibleRooms ( ) ;
743
+ const visibleRooms = this . matrixClient . getVisibleRooms ( this . _msc3946ProcessDynamicPredecessor ) ;
733
744
734
745
const prevRoomsBySpace = this . roomIdsBySpace ;
735
746
const prevUsersBySpace = this . userIdsBySpace ;
@@ -792,7 +803,9 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
792
803
// Expand room IDs to all known versions of the given rooms
793
804
const expandedRoomIds = new Set (
794
805
Array . from ( roomIds ) . flatMap ( ( roomId ) => {
795
- return this . matrixClient . getRoomUpgradeHistory ( roomId , true ) . map ( ( r ) => r . roomId ) ;
806
+ return this . matrixClient
807
+ . getRoomUpgradeHistory ( roomId , true , this . _msc3946ProcessDynamicPredecessor )
808
+ . map ( ( r ) => r . roomId ) ;
796
809
} ) ,
797
810
) ;
798
811
@@ -1275,6 +1288,13 @@ export class SpaceStoreClass extends AsyncStoreWithClient<IState> {
1275
1288
this . updateNotificationStates ( [ payload . roomId ] ) ;
1276
1289
}
1277
1290
break ;
1291
+
1292
+ case "feature_dynamic_room_predecessors" :
1293
+ this . _msc3946ProcessDynamicPredecessor = SettingsStore . getValue (
1294
+ "feature_dynamic_room_predecessors" ,
1295
+ ) ;
1296
+ this . rebuildSpaceHierarchy ( ) ;
1297
+ break ;
1278
1298
}
1279
1299
}
1280
1300
}
@@ -1355,6 +1375,15 @@ export default class SpaceStore {
1355
1375
public static get instance ( ) : SpaceStoreClass {
1356
1376
return SpaceStore . internalInstance ;
1357
1377
}
1378
+
1379
+ /**
1380
+ * @internal for test only
1381
+ */
1382
+ public static testInstance ( ) : SpaceStoreClass {
1383
+ const store = new SpaceStoreClass ( ) ;
1384
+ store . start ( ) ;
1385
+ return store ;
1386
+ }
1358
1387
}
1359
1388
1360
1389
window . mxSpaceStore = SpaceStore . instance ;
0 commit comments