Replace uses of checkDeviceTrust
with getDeviceVerificationStatus
(#10663)
matrix-org/matrix-js-sdk#3287 and matrix-org/matrix-js-sdk#3303 added a new API called getDeviceVerificationStatus. Let's use it.
This commit is contained in:
parent
aa8c0f5cc7
commit
d7bb8043ea
22 changed files with 286 additions and 161 deletions
|
@ -50,24 +50,26 @@ const parseDeviceExtendedInformation = (matrixClient: MatrixClient, device: IMyD
|
|||
};
|
||||
};
|
||||
|
||||
const fetchDevicesWithVerification = async (matrixClient: MatrixClient): Promise<DevicesState["devices"]> => {
|
||||
/**
|
||||
* Fetch extended details of the user's own devices
|
||||
*
|
||||
* @param matrixClient - Matrix Client
|
||||
* @returns A dictionary mapping from device ID to ExtendedDevice
|
||||
*/
|
||||
export async function fetchExtendedDeviceInformation(matrixClient: MatrixClient): Promise<DevicesDictionary> {
|
||||
const { devices } = await matrixClient.getDevices();
|
||||
|
||||
const devicesDict = devices.reduce(
|
||||
(acc, device: IMyDevice) => ({
|
||||
...acc,
|
||||
[device.device_id]: {
|
||||
...device,
|
||||
isVerified: isDeviceVerified(matrixClient, device.device_id),
|
||||
...parseDeviceExtendedInformation(matrixClient, device),
|
||||
...parseUserAgent(device[UNSTABLE_MSC3852_LAST_SEEN_UA.name]),
|
||||
},
|
||||
}),
|
||||
{},
|
||||
);
|
||||
|
||||
const devicesDict: DevicesDictionary = {};
|
||||
for (const device of devices) {
|
||||
devicesDict[device.device_id] = {
|
||||
...device,
|
||||
isVerified: await isDeviceVerified(matrixClient, device.device_id),
|
||||
...parseDeviceExtendedInformation(matrixClient, device),
|
||||
...parseUserAgent(device[UNSTABLE_MSC3852_LAST_SEEN_UA.name]),
|
||||
};
|
||||
}
|
||||
return devicesDict;
|
||||
};
|
||||
}
|
||||
|
||||
export enum OwnDevicesError {
|
||||
Unsupported = "Unsupported",
|
||||
|
@ -112,7 +114,7 @@ export const useOwnDevices = (): DevicesState => {
|
|||
const refreshDevices = useCallback(async (): Promise<void> => {
|
||||
setIsLoadingDeviceList(true);
|
||||
try {
|
||||
const devices = await fetchDevicesWithVerification(matrixClient);
|
||||
const devices = await fetchExtendedDeviceInformation(matrixClient);
|
||||
setDevices(devices);
|
||||
|
||||
const { pushers } = await matrixClient.getPushers();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue