@@ -60,6 +60,33 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
6060 return this . matrixClient && this . matrixClient . getVisibleRooms ( ) . length >= 20 ;
6161 }
6262
63+ componentDidUpdate ( prevProps , prevState ) {
64+ const prevRoomCount = ( prevState . rooms ?. length || 0 ) ;
65+ const currentRoomCount = ( this . state . rooms ?. length || 0 )
66+
67+ /**
68+ * Only decrypting the breadcrumb rooms events on app initialisation
69+ * when room count transitions from 0 to the number of rooms it contains
70+ */
71+ if ( prevRoomCount === 0 && currentRoomCount > prevRoomCount ) {
72+ const client = MatrixClientPeg . get ( ) ;
73+ /**
74+ * Rooms in the breadcrumb have a good chance to be interacted with
75+ * again by a user. Decrypting the messages ahead of time will help
76+ * reduce content shift on first render
77+ */
78+ this . state . rooms ?. forEach ( async room => {
79+ const [ cryptoEvent ] = room . currentState . getStateEvents ( "m.room.encryption" ) ;
80+ if ( cryptoEvent ) {
81+ if ( ! client . isRoomEncrypted ( room . roomId ) ) {
82+ await client . _crypto . onCryptoEvent ( cryptoEvent ) ;
83+ }
84+ room ?. decryptAllEvents ( ) ;
85+ }
86+ } ) ;
87+ }
88+ }
89+
6390 protected async onAction ( payload : ActionPayload ) {
6491 if ( ! this . matrixClient ) return ;
6592
@@ -88,23 +115,6 @@ export class BreadcrumbsStore extends AsyncStoreWithClient<IState> {
88115
89116 this . matrixClient . on ( "Room.myMembership" , this . onMyMembership ) ;
90117 this . matrixClient . on ( "Room" , this . onRoom ) ;
91-
92- const client = MatrixClientPeg . get ( ) ;
93- const breadcrumbs = client . store . getAccountData ( "im.vector.setting.breadcrumbs" ) ;
94- const breadcrumbsRooms : string [ ] = breadcrumbs ?. getContent ( ) . recent_rooms || [ ] ;
95-
96- breadcrumbsRooms . map ( async roomId => {
97- const room = client . getRoom ( roomId ) ;
98- if ( room ) {
99- const [ cryptoEvent ] = room . currentState . getStateEvents ( "m.room.encryption" ) ;
100- if ( cryptoEvent ) {
101- if ( ! client . isRoomEncrypted ( roomId ) ) {
102- await client . _crypto . onCryptoEvent ( cryptoEvent ) ;
103- }
104- return room ?. decryptAllEvents ( ) ;
105- }
106- }
107- } ) ;
108118 }
109119
110120 protected async onNotReady ( ) {
0 commit comments