From a70efea69e9c1bda8419e24770f70aa8cc057a8f Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 29 Apr 2020 17:16:04 +0100 Subject: [PATCH 1/2] Treat sessions that are there when we log in as old Use the bulk 'review' toast for sessions that existed at the time of login, rather than considering them all to be new. Also cheeky unrelated proptypes fix. Fixes https://github.com/vector-im/riot-web/issues/13443 Requires https://github.com/matrix-org/matrix-js-sdk/pull/1360 --- src/DeviceListener.js | 13 ++++++++++--- .../views/toasts/UnverifiedSessionToast.js | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/DeviceListener.js b/src/DeviceListener.js index 84c6b1d230..c37d702fd6 100644 --- a/src/DeviceListener.js +++ b/src/DeviceListener.js @@ -107,7 +107,12 @@ export default class DeviceListener { } } - _onWillUpdateDevices = async (users) => { + _onWillUpdateDevices = async (users, initialFetch) => { + // We we didn't know about *any* devices before (ie. it's fresh login), + // then they are all pre-existing devices, so ignore this and set the + // devicesAtStart list to the devices that we see after the fetch. + if (initialFetch) return; + const myUserId = MatrixClientPeg.get().getUserId(); if (users.includes(myUserId)) this._ensureDeviceIdsAtStartPopulated(); @@ -179,8 +184,6 @@ export default class DeviceListener { const crossSigningReady = await cli.isCrossSigningReady(); - this._ensureDeviceIdsAtStartPopulated(); - if (this._dismissedThisDeviceToast) { ToastStore.sharedInstance().dismissToast(THIS_DEVICE_TOAST_KEY); } else { @@ -235,6 +238,10 @@ export default class DeviceListener { } } + // This needs to be done after awaiting on downloadKeys() above, so + // we make sure we get the devices after the fetch is done. + this._ensureDeviceIdsAtStartPopulated(); + // Unverified devices that were there last time the app ran // (technically could just be a boolean: we don't actually // need to remember the device IDs, but for the sake of diff --git a/src/components/views/toasts/UnverifiedSessionToast.js b/src/components/views/toasts/UnverifiedSessionToast.js index 032d457c3a..f3e35e247c 100644 --- a/src/components/views/toasts/UnverifiedSessionToast.js +++ b/src/components/views/toasts/UnverifiedSessionToast.js @@ -27,7 +27,7 @@ import { replaceableComponent } from '../../../utils/replaceableComponent'; @replaceableComponent("views.toasts.UnverifiedSessionToast") export default class UnverifiedSessionToast extends React.PureComponent { static propTypes = { - deviceId: PropTypes.object, + deviceId: PropTypes.string, } _onLaterClick = () => { From c41af152ac70c3ee97fb9e7c6911de2e1e86be9e Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 29 Apr 2020 17:33:18 +0100 Subject: [PATCH 2/2] Comment typo Co-Authored-By: J. Ryan Stinnett --- src/DeviceListener.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DeviceListener.js b/src/DeviceListener.js index c37d702fd6..28f8e8b115 100644 --- a/src/DeviceListener.js +++ b/src/DeviceListener.js @@ -108,7 +108,7 @@ export default class DeviceListener { } _onWillUpdateDevices = async (users, initialFetch) => { - // We we didn't know about *any* devices before (ie. it's fresh login), + // If we didn't know about *any* devices before (ie. it's fresh login), // then they are all pre-existing devices, so ignore this and set the // devicesAtStart list to the devices that we see after the fetch. if (initialFetch) return;