@@ -671,6 +671,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
671
671
// the RoomView instance
672
672
if ( initial ) {
673
673
newState . room = this . context . client ! . getRoom ( newState . roomId ) || undefined ;
674
+ newState . isRoomEncrypted = null ;
674
675
if ( newState . room ) {
675
676
newState . showApps = this . shouldShowApps ( newState . room ) ;
676
677
this . onRoomLoaded ( newState . room ) ;
@@ -713,6 +714,14 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
713
714
if ( initial ) {
714
715
this . setupRoom ( newState . room , newState . roomId , ! ! newState . joining , ! ! newState . shouldPeek ) ;
715
716
}
717
+
718
+ // We don't block the initial setup but we want to make it early to not block the timeline rendering
719
+ const isRoomEncrypted = await this . getIsRoomEncrypted ( newState . roomId ) ;
720
+ this . setState ( {
721
+ isRoomEncrypted,
722
+ ...( isRoomEncrypted &&
723
+ newState . roomId && { e2eStatus : RoomView . e2eStatusCache . get ( newState . roomId ) ?? E2EStatus . Warning } ) ,
724
+ } ) ;
716
725
} ;
717
726
718
727
private onConnectedCalls = ( ) : void => {
@@ -863,7 +872,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
863
872
return isManuallyShown && widgets . length > 0 ;
864
873
}
865
874
866
- public async componentDidMount ( ) : Promise < void > {
875
+ public componentDidMount ( ) : void {
867
876
this . unmounted = false ;
868
877
869
878
this . dispatcherRef = defaultDispatcher . register ( this . onAction ) ;
@@ -1482,24 +1491,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1482
1491
1483
1492
private async updateE2EStatus ( room : Room ) : Promise < void > {
1484
1493
if ( ! this . context . client || ! this . state . isRoomEncrypted ) return ;
1485
-
1486
- // If crypto is not currently enabled, we aren't tracking devices at all,
1487
- // so we don't know what the answer is. Let's error on the safe side and show
1488
- // a warning for this case.
1489
- let e2eStatus = RoomView . e2eStatusCache . get ( room . roomId ) ?? E2EStatus . Warning ;
1490
- // set the state immediately then update, so we don't scare the user into thinking the room is unencrypted
1494
+ const e2eStatus = await this . cacheAndGetE2EStatus ( room , this . context . client ) ;
1495
+ if ( this . unmounted ) return ;
1491
1496
this . setState ( { e2eStatus } ) ;
1492
-
1493
- if ( this . context . client . getCrypto ( ) ) {
1494
- /* At this point, the user has encryption on and cross-signing on */
1495
- e2eStatus = await this . cacheAndGetE2EStatus ( room , this . context . client ) ;
1496
- if ( this . unmounted ) return ;
1497
- this . setState ( { e2eStatus } ) ;
1498
- }
1499
1497
}
1500
1498
1501
1499
private async cacheAndGetE2EStatus ( room : Room , client : MatrixClient ) : Promise < E2EStatus > {
1502
- const e2eStatus = await shieldStatusForRoom ( client , room ) ;
1500
+ let e2eStatus = RoomView . e2eStatusCache . get ( room . roomId ) ;
1501
+ // set the state immediately then update, so we don't scare the user into thinking the room is unencrypted
1502
+ if ( e2eStatus ) this . setState ( { e2eStatus } ) ;
1503
+
1504
+ e2eStatus = await shieldStatusForRoom ( client , room ) ;
1503
1505
RoomView . e2eStatusCache . set ( room . roomId , e2eStatus ) ;
1504
1506
return e2eStatus ;
1505
1507
}
0 commit comments