@@ -400,6 +400,10 @@ function LocalRoomCreateLoader(props: ILocalRoomCreateLoaderProps): ReactElement
400
400
}
401
401
402
402
export class RoomView extends React . Component < IRoomProps , IRoomState > {
403
+ // We cache the latest computed e2eStatus per room to show as soon as we switch rooms otherwise defaulting to
404
+ // unencrypted causes a flicker which can yield confusion/concern in a larger room.
405
+ private static e2eStatusCache = new Map < string , E2EStatus > ( ) ;
406
+
403
407
private readonly askToJoinEnabled : boolean ;
404
408
private readonly dispatcherRef : string ;
405
409
private settingWatchers : string [ ] ;
@@ -1530,14 +1534,18 @@ export class RoomView extends React.Component<IRoomProps, IRoomState> {
1530
1534
// If crypto is not currently enabled, we aren't tracking devices at all,
1531
1535
// so we don't know what the answer is. Let's error on the safe side and show
1532
1536
// a warning for this case.
1533
- let e2eStatus = E2EStatus . Warning ;
1537
+ let e2eStatus = RoomView . e2eStatusCache . get ( room . roomId ) ?? E2EStatus . Warning ;
1538
+ // set the state immediately then update, so we don't scare the user into thinking the room is unencrypted
1539
+ this . setState ( { e2eStatus } ) ;
1540
+
1534
1541
if ( this . context . client . isCryptoEnabled ( ) ) {
1542
+ this . setState ( { e2eStatus : E2EStatus . Normal } ) ;
1535
1543
/* At this point, the user has encryption on and cross-signing on */
1536
1544
e2eStatus = await shieldStatusForRoom ( this . context . client , room ) ;
1545
+ RoomView . e2eStatusCache . set ( room . roomId , e2eStatus ) ;
1546
+ if ( this . unmounted ) return ;
1547
+ this . setState ( { e2eStatus } ) ;
1537
1548
}
1538
-
1539
- if ( this . unmounted ) return ;
1540
- this . setState ( { e2eStatus } ) ;
1541
1549
}
1542
1550
1543
1551
private onUrlPreviewsEnabledChange = ( ) : void => {
0 commit comments