@@ -79,6 +79,7 @@ import PosthogTrackers from "../../../PosthogTrackers";
7979import { ViewRoomPayload } from "../../../dispatcher/payloads/ViewRoomPayload" ;
8080import { DirectoryMember , startDmOnFirstMessage } from "../../../utils/direct-messages" ;
8181import { SdkContextClass } from "../../../contexts/SDKContext" ;
82+ import { asyncSome } from "../../../utils/arrays" ;
8283
8384export interface IDevice extends DeviceInfo {
8485 ambiguous ?: boolean ;
@@ -101,22 +102,22 @@ export const disambiguateDevices = (devices: IDevice[]): void => {
101102 }
102103} ;
103104
104- export const getE2EStatus = ( cli : MatrixClient , userId : string , devices : IDevice [ ] ) : E2EStatus => {
105+ export const getE2EStatus = async ( cli : MatrixClient , userId : string , devices : IDevice [ ] ) : Promise < E2EStatus > => {
105106 const isMe = userId === cli . getUserId ( ) ;
106107 const userTrust = cli . checkUserTrust ( userId ) ;
107108 if ( ! userTrust . isCrossSigningVerified ( ) ) {
108109 return userTrust . wasCrossSigningVerified ( ) ? E2EStatus . Warning : E2EStatus . Normal ;
109110 }
110111
111- const anyDeviceUnverified = devices . some ( ( device ) => {
112+ const anyDeviceUnverified = await asyncSome ( devices , async ( device ) => {
112113 const { deviceId } = device ;
113114 // For your own devices, we use the stricter check of cross-signing
114115 // verification to encourage everyone to trust their own devices via
115116 // cross-signing so that other users can then safely trust you.
116117 // For other people's devices, the more general verified check that
117118 // includes locally verified devices can be used.
118- const deviceTrust = cli . checkDeviceTrust ( userId , deviceId ) ;
119- return isMe ? ! deviceTrust . isCrossSigningVerified ( ) : ! deviceTrust . isVerified ( ) ;
119+ const deviceTrust = await cli . getCrypto ( ) ?. getDeviceVerificationStatus ( userId , deviceId ) ;
120+ return isMe ? ! deviceTrust ?. crossSigningVerified : ! deviceTrust ? .isVerified ( ) ;
120121 } ) ;
121122 return anyDeviceUnverified ? E2EStatus . Warning : E2EStatus . Verified ;
122123} ;
@@ -1611,10 +1612,13 @@ const UserInfo: React.FC<IProps> = ({ user, room, onClose, phase = RightPanelPha
16111612 const isRoomEncrypted = useIsEncrypted ( cli , room ) ;
16121613 const devices = useDevices ( user . userId ) ?? [ ] ;
16131614
1614- let e2eStatus : E2EStatus | undefined ;
1615- if ( isRoomEncrypted && devices ) {
1616- e2eStatus = getE2EStatus ( cli , user . userId , devices ) ;
1617- }
1615+ const e2eStatus = useAsyncMemo ( async ( ) => {
1616+ if ( ! isRoomEncrypted || ! devices ) {
1617+ return undefined ;
1618+ } else {
1619+ return await getE2EStatus ( cli , user . userId , devices ) ;
1620+ }
1621+ } , [ cli , isRoomEncrypted , user . userId , devices ] ) ;
16181622
16191623 const classes = [ "mx_UserInfo" ] ;
16201624
0 commit comments