@@ -671,6 +671,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
671671 // the RoomView instance
672672 if ( initial ) {
673673 newState . room = this . context . client ! . getRoom ( newState . roomId ) || undefined ;
674+ newState . isRoomEncrypted = null ;
674675 if ( newState . room ) {
675676 newState . showApps = this . shouldShowApps ( newState . room ) ;
676677 this . onRoomLoaded ( newState . room ) ;
@@ -713,6 +714,14 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
713714 if ( initial ) {
714715 this . setupRoom ( newState . room , newState . roomId , ! ! newState . joining , ! ! newState . shouldPeek ) ;
715716 }
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+ } ) ;
716725 } ;
717726
718727 private onConnectedCalls = ( ) : void => {
@@ -863,7 +872,7 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
863872 return isManuallyShown && widgets . length > 0 ;
864873 }
865874
866- public async componentDidMount ( ) : Promise < void > {
875+ public componentDidMount ( ) : void {
867876 this . unmounted = false ;
868877
869878 this . dispatcherRef = defaultDispatcher . register ( this . onAction ) ;
@@ -1482,24 +1491,17 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
14821491
14831492 private async updateE2EStatus ( room : Room ) : Promise < void > {
14841493 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 ;
14911496 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- }
14991497 }
15001498
15011499 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 ) ;
15031505 RoomView . e2eStatusCache . set ( room . roomId , e2eStatus ) ;
15041506 return e2eStatus ;
15051507 }
0 commit comments