@@ -77,10 +77,12 @@ interface IState {
7777 sublists : ITagMap ;
7878 currentRoomId ?: string ;
7979 suggestedRooms : ISuggestedRoom [ ] ;
80+ feature_favourite_messages : boolean ;
8081}
8182
8283export const TAG_ORDER : TagID [ ] = [
8384 DefaultTagID . Invite ,
85+ DefaultTagID . SavedItems ,
8486 DefaultTagID . Favourite ,
8587 DefaultTagID . DM ,
8688 DefaultTagID . Untagged ,
@@ -351,6 +353,11 @@ const TAG_AESTHETICS: ITagAestheticsMap = {
351353 isInvite : false ,
352354 defaultHidden : false ,
353355 } ,
356+ [ DefaultTagID . SavedItems ] : {
357+ sectionLabel : _td ( "Saved Items" ) ,
358+ isInvite : false ,
359+ defaultHidden : false ,
360+ } ,
354361 [ DefaultTagID . DM ] : {
355362 sectionLabel : _td ( "People" ) ,
356363 isInvite : false ,
@@ -392,6 +399,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
392399 private dispatcherRef ;
393400 private roomStoreToken : fbEmitter . EventSubscription ;
394401 private treeRef = createRef < HTMLDivElement > ( ) ;
402+ private favouriteMessageWatcher : string ;
395403
396404 static contextType = MatrixClientContext ;
397405 public context ! : React . ContextType < typeof MatrixClientContext > ;
@@ -402,6 +410,7 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
402410 this . state = {
403411 sublists : { } ,
404412 suggestedRooms : SpaceStore . instance . suggestedRooms ,
413+ feature_favourite_messages : SettingsStore . getValue ( "feature_favourite_messages" ) ,
405414 } ;
406415 }
407416
@@ -410,12 +419,17 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
410419 this . roomStoreToken = RoomViewStore . instance . addListener ( this . onRoomViewStoreUpdate ) ;
411420 SpaceStore . instance . on ( UPDATE_SUGGESTED_ROOMS , this . updateSuggestedRooms ) ;
412421 RoomListStore . instance . on ( LISTS_UPDATE_EVENT , this . updateLists ) ;
422+ this . favouriteMessageWatcher =
423+ SettingsStore . watchSetting ( "feature_favourite_messages" , null , ( ...[ , , , value ] ) => {
424+ this . setState ( { feature_favourite_messages : value } ) ;
425+ } ) ;
413426 this . updateLists ( ) ; // trigger the first update
414427 }
415428
416429 public componentWillUnmount ( ) {
417430 SpaceStore . instance . off ( UPDATE_SUGGESTED_ROOMS , this . updateSuggestedRooms ) ;
418431 RoomListStore . instance . off ( LISTS_UPDATE_EVENT , this . updateLists ) ;
432+ SettingsStore . unwatchSetting ( this . favouriteMessageWatcher ) ;
419433 defaultDispatcher . unregister ( this . dispatcherRef ) ;
420434 if ( this . roomStoreToken ) this . roomStoreToken . remove ( ) ;
421435 }
@@ -545,6 +559,28 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
545559 ) ;
546560 } ) ;
547561 }
562+ private renderFavoriteMessagesList ( ) : ReactComponentElement < typeof ExtraTile > [ ] {
563+ const avatar = (
564+ < RoomAvatar
565+ oobData = { {
566+ name : "Favourites" ,
567+ } }
568+ width = { 32 }
569+ height = { 32 }
570+ resizeMethod = "crop"
571+ /> ) ;
572+
573+ return [
574+ < ExtraTile
575+ isMinimized = { this . props . isMinimized }
576+ isSelected = { false }
577+ displayName = "Favourite Messages"
578+ avatar = { avatar }
579+ onClick = { ( ) => "" }
580+ key = "favMessagesTile_key"
581+ /> ,
582+ ] ;
583+ }
548584
549585 private renderSublists ( ) : React . ReactElement [ ] {
550586 // show a skeleton UI if the user is in no rooms and they are not filtering and have no suggested rooms
@@ -558,6 +594,12 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
558594 extraTiles = this . renderSuggestedRooms ( ) ;
559595 }
560596
597+ if ( this . state . feature_favourite_messages && orderedTagId === DefaultTagID . SavedItems ) {
598+ extraTiles = this . renderFavoriteMessagesList ( ) ;
599+ } else {
600+ extraTiles = null ;
601+ }
602+
561603 const aesthetics = TAG_AESTHETICS [ orderedTagId ] ;
562604 if ( ! aesthetics ) throw new Error ( `Tag ${ orderedTagId } does not have aesthetics` ) ;
563605
@@ -582,7 +624,6 @@ export default class RoomList extends React.PureComponent<IProps, IState> {
582624 ) {
583625 forceExpanded = true ;
584626 }
585-
586627 // The cost of mounting/unmounting this component offsets the cost
587628 // of keeping it in the DOM and hiding it when it is not required
588629 return < RoomSublist
0 commit comments