Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 74d5696

Browse files
committed
UserInfo step 3: DevicesSection
1 parent edfad2b commit 74d5696

File tree

3 files changed

+9
-10
lines changed

3 files changed

+9
-10
lines changed

src/components/views/right_panel/UserInfo.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,17 @@ function DevicesSection({
242242

243243
const [isExpanded, setExpanded] = useState(false);
244244

245-
if (loading) {
245+
const deviceTrusts = useAsyncMemo(() => {
246+
const cryptoApi = cli.getCrypto();
247+
if (!cryptoApi) return Promise.resolve(undefined);
248+
return Promise.all(devices.map((d) => cryptoApi.getDeviceVerificationStatus(userId, d.deviceId)));
249+
}, [cli, userId, devices]);
250+
251+
if (loading || deviceTrusts === undefined) {
246252
// still loading
247253
return <Spinner />;
248254
}
249-
if (devices === null) {
250-
return <p>{_t("Unable to load session list")}</p>;
251-
}
252255
const isMe = userId === cli.getUserId();
253-
const deviceTrusts = devices.map((d) => cli.checkDeviceTrust(userId, d.deviceId));
254256

255257
let expandSectionDevices: IDevice[] = [];
256258
const unverifiedDevices: IDevice[] = [];
@@ -268,7 +270,7 @@ function DevicesSection({
268270
// cross-signing so that other users can then safely trust you.
269271
// For other people's devices, the more general verified check that
270272
// includes locally verified devices can be used.
271-
const isVerified = isMe ? deviceTrust.isCrossSigningVerified() : deviceTrust.isVerified();
273+
const isVerified = deviceTrust && (isMe ? deviceTrust.crossSigningVerified : deviceTrust.isVerified());
272274

273275
if (isVerified) {
274276
expandSectionDevices.push(device);

src/i18n/strings/en_EN.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2252,7 +2252,6 @@
22522252
"Room settings": "Room settings",
22532253
"Trusted": "Trusted",
22542254
"Not trusted": "Not trusted",
2255-
"Unable to load session list": "Unable to load session list",
22562255
"%(count)s verified sessions|other": "%(count)s verified sessions",
22572256
"%(count)s verified sessions|one": "1 verified session",
22582257
"Hide verified sessions": "Hide verified sessions",

test/components/views/right_panel/UserInfo-test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import {
2929
DeviceVerificationStatus,
3030
} from "matrix-js-sdk/src/matrix";
3131
import { Phase, VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
32-
import { DeviceTrustLevel, UserTrustLevel } from "matrix-js-sdk/src/crypto/CrossSigning";
32+
import { UserTrustLevel } from "matrix-js-sdk/src/crypto/CrossSigning";
3333
import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
3434
import { defer } from "matrix-js-sdk/src/utils";
3535

@@ -148,7 +148,6 @@ beforeEach(() => {
148148
currentState: {
149149
on: jest.fn(),
150150
},
151-
checkDeviceTrust: jest.fn(),
152151
checkUserTrust: jest.fn(),
153152
getRoom: jest.fn(),
154153
credentials: {},
@@ -266,7 +265,6 @@ describe("<UserInfo />", () => {
266265
beforeEach(() => {
267266
mockClient.isCryptoEnabled.mockReturnValue(true);
268267
mockClient.checkUserTrust.mockReturnValue(new UserTrustLevel(false, false, false));
269-
mockClient.checkDeviceTrust.mockReturnValue(new DeviceTrustLevel(false, false, false, false));
270268

271269
const device1 = DeviceInfo.fromStorage(
272270
{

0 commit comments

Comments
 (0)