From d842944f61bdef92f44262a13e21f4690405c5f1 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 21 Apr 2020 18:36:15 +0200 Subject: [PATCH] wait until cross-signing keys are fetched to show verify button --- src/components/views/right_panel/UserInfo.js | 38 ++++++++++++-------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/components/views/right_panel/UserInfo.js b/src/components/views/right_panel/UserInfo.js index abe54b355e..65519270b5 100644 --- a/src/components/views/right_panel/UserInfo.js +++ b/src/components/views/right_panel/UserInfo.js @@ -142,7 +142,7 @@ function useIsEncrypted(cli, room) { function useHasCrossSigningKeys(cli, member, canVerify, setUpdating) { return useAsyncMemo(async () => { if (!canVerify) { - return false; + return undefined; } setUpdating(true); try { @@ -153,7 +153,7 @@ function useHasCrossSigningKeys(cli, member, canVerify, setUpdating) { } finally { setUpdating(false); } - }, [cli, member, canVerify], false); + }, [cli, member, canVerify], undefined); } function DeviceItem({userId, device}) { @@ -1307,18 +1307,28 @@ const BasicUserInfo = ({room, member, groupId, devices, isRoomEncrypted}) => { const hasCrossSigningKeys = useHasCrossSigningKeys(cli, member, canVerify, setUpdating ); + const showDeviceListSpinner = devices === undefined; if (canVerify) { - verifyButton = ( - { - if (hasCrossSigningKeys) { - verifyUser(member); - } else { - legacyVerifyUser(member); - } - }}> - {_t("Verify")} - - ); + if (hasCrossSigningKeys !== undefined) { + // Note: mx_UserInfo_verifyButton is for the end-to-end tests + verifyButton = ( + { + if (hasCrossSigningKeys) { + verifyUser(member); + } else { + legacyVerifyUser(member); + } + }}> + {_t("Verify")} + + ); + } else if (!showDeviceListSpinner) { + // HACK: only show a spinner if the device section spinner is not shown, + // to avoid showing a double spinner + // We should ask for a design that includes all the different loading states here + const Spinner = sdk.getComponent('elements.Spinner'); + verifyButton = ; + } } const securitySection = ( @@ -1327,7 +1337,7 @@ const BasicUserInfo = ({room, member, groupId, devices, isRoomEncrypted}) => {

{ text }

{ verifyButton }