From 7a5bf8f1022562530fd0c1754728404f645f0ca3 Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 29 Jan 2020 21:55:27 +0000 Subject: [PATCH 1/3] Update user info for device and trust changes This ensure the user info panel updates automatically for device and trust changes. Fixes https://github.com/vector-im/riot-web/issues/12134` --- src/DeviceListener.js | 4 +-- src/components/views/right_panel/UserInfo.js | 30 +++++++++++++------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/DeviceListener.js b/src/DeviceListener.js index 4bc6ce2097..4e7bc8470d 100644 --- a/src/DeviceListener.js +++ b/src/DeviceListener.js @@ -77,8 +77,8 @@ export default class DeviceListener { this._recheck(); } - _onDeviceVerificationChanged = (users) => { - if (!users.includes(MatrixClientPeg.get().getUserId())) return; + _onDeviceVerificationChanged = (userId) => { + if (userId !== MatrixClientPeg.get().getUserId()) return; this._recheck(); } diff --git a/src/components/views/right_panel/UserInfo.js b/src/components/views/right_panel/UserInfo.js index 5a5d9a577c..154d564f05 100644 --- a/src/components/views/right_panel/UserInfo.js +++ b/src/components/views/right_panel/UserInfo.js @@ -1092,22 +1092,32 @@ export const useDevices = (userId) => { // Listen to changes useEffect(() => { let cancel = false; - const onDeviceVerificationChanged = (_userId, device) => { - if (_userId === userId) { - // no need to re-download the whole thing; just update our copy of the list. - - // Promise.resolve to handle transition from static result to promise; can be removed in future - Promise.resolve(cli.getStoredDevicesForUser(userId)).then((devices) => { - if (cancel) return; - setDevices(devices); - }); - } + const updateDevices = async () => { + const newDevices = await cli.getStoredDevicesForUser(userId); + if (cancel) return; + setDevices(newDevices); }; + const onDevicesUpdated = (users) => { + if (!users.includes(userId)) return; + updateDevices(); + }; + const onDeviceVerificationChanged = (_userId, device) => { + if (_userId !== userId) return; + updateDevices(); + }; + const onUserTrustStatusChanged = (_userId, trustStatus) => { + if (_userId !== userId) return; + updateDevices(); + }; + cli.on("crypto.devicesUpdated", onDevicesUpdated); cli.on("deviceVerificationChanged", onDeviceVerificationChanged); + cli.on("userTrustStatusChanged", onUserTrustStatusChanged); // Handle being unmounted return () => { cancel = true; + cli.removeListener("crypto.devicesUpdated", onDevicesUpdated); cli.removeListener("deviceVerificationChanged", onDeviceVerificationChanged); + cli.removeListener("userTrustStatusChanged", onUserTrustStatusChanged); }; }, [cli, userId]); From eaa48665d2af50b4e09c9f81548e3c1d25017c9b Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Wed, 29 Jan 2020 21:59:30 +0000 Subject: [PATCH 2/3] Guard request input --- src/components/views/right_panel/EncryptionPanel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/views/right_panel/EncryptionPanel.js b/src/components/views/right_panel/EncryptionPanel.js index f25a55fa8a..2b3196f4c1 100644 --- a/src/components/views/right_panel/EncryptionPanel.js +++ b/src/components/views/right_panel/EncryptionPanel.js @@ -36,7 +36,7 @@ const EncryptionPanel = ({verificationRequest, member, onClose}) => { setRequest(verificationRequest); }, [verificationRequest]); - const [phase, setPhase] = useState(request.phase); + const [phase, setPhase] = useState(request && request.phase); const changeHandler = useCallback(() => { // handle transitions -> cancelled for mismatches which fire a modal instead of showing a card if (request && request.cancelled && MISMATCHES.includes(request.cancellationCode)) { From a180dddc669d9781bdd567c9c88d30b429ec7cdc Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 29 Jan 2020 22:31:19 +0000 Subject: [PATCH 3/3] Pass an ID to the as needed and fix div inside p nesting Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- .../dialogs/secretstorage/_CreateSecretStorageDialog.scss | 4 ++++ .../dialogs/secretstorage/CreateSecretStorageDialog.js | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/res/css/views/dialogs/secretstorage/_CreateSecretStorageDialog.scss b/res/css/views/dialogs/secretstorage/_CreateSecretStorageDialog.scss index bbbf3fc1d3..a9ebd54b31 100644 --- a/res/css/views/dialogs/secretstorage/_CreateSecretStorageDialog.scss +++ b/res/css/views/dialogs/secretstorage/_CreateSecretStorageDialog.scss @@ -37,6 +37,10 @@ limitations under the License. flex: 0 0 auto; margin-left: 30px; } + + details .mx_AccessibleButton { + margin: 1em 0; // emulate paragraph spacing because we can't put this button in a paragraph due to HTML rules + } } .mx_CreateSecretStorageDialog .mx_Dialog_title { diff --git a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js index c3b74381ff..64aff467a7 100644 --- a/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js +++ b/src/async-components/views/dialogs/secretstorage/CreateSecretStorageDialog.js @@ -480,7 +480,9 @@ export default class CreateSecretStorageDialog extends React.PureComponent { )}

- {_t("Advanced")} -

+ {_t("Set up with a recovery key")} -

+
; }