Page MenuHomePhabricator

[lib] add new selector and function to get own user's keyserver device ID
ClosedPublic

Authored by varun on Jul 19 2024, 2:18 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 8, 1:33 AM
Unknown Object (File)
Fri, Oct 25, 2:38 AM
Unknown Object (File)
Fri, Oct 25, 2:38 AM
Unknown Object (File)
Oct 1 2024, 2:19 PM
Unknown Object (File)
Sep 25 2024, 1:31 AM
Unknown Object (File)
Sep 25 2024, 1:31 AM
Unknown Object (File)
Sep 25 2024, 1:29 AM
Unknown Object (File)
Sep 18 2024, 5:11 PM
Subscribers

Details

Summary

we'll use this to check if the logged in user already has a keyserver associated with their account. if they do, we'll need to prompt them to either cancel the attempt to add a new keyserver or OK replacing the old keyserver with the new one

i moved the olm session types to their own file to avoid a circular dependency

Depends on D12805

Test Plan

tested in next diff by scanning a second keyserver's QR code and successfully replacing the first keyserver in device list

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

varun requested review of this revision.Jul 19 2024, 2:34 PM
ashoat added inline comments.
lib/selectors/user-selectors.js
256–259 ↗(On Diff #42558)

These need to be read-only. The way you've typed it, you're allowing a caller of getOwnPeerDevices to directly mutate the Redux state, which should never be possible. The Redux state should only change in response to actions being reduced

262 ↗(On Diff #42558)

This function is named in a similar way to the one above (getForeignPeerDevices), but it returns something different.

  1. Can you clarify why we need PlatformDetails here but not above?
  2. In a separate diff, can you either update the naming to be more clear (ie. maybe rename getForeignPeerDevices to getForeignPeerDeviceIDs), or update getForeignPeerDevices to also return $ReadOnlyArray<DeviceIDAndPlatformDetails>?
269–275 ↗(On Diff #42558)

I don't love this use of ternary and ??. I think this is more readable:

if (!currentUserID) {
  return [];
}
const devices = auxUserInfos[currentUserID]?.deviceList?.devices;
if (!devices) {
  return [];
}
return devices.map(deviceID => ({
  deviceID,
  platformDetails:
    auxUserInfos[currentUserID].devicesPlatformDetails?.[deviceID],
}));
lib/types/olm-session-types.js
1–33 ↗(On Diff #42558)

It looks like this diff includes a move. In the future, please make sure you always separate code refactors like this into their own diffs. See here:

{F2381628}

This revision is now accepted and ready to land.Aug 2 2024, 9:23 AM
ashoat added a subscriber: kamil.

(Removing @tomek and @kamil to clear up their queue, as I think they were only added because @bartek and I were taking so long to review this. Sorry about that!)

lib/selectors/user-selectors.js
262 ↗(On Diff #42558)
  1. We want the platform details so we can display the device type when we list a user's devices in D12907. We also use it in the next diff to see if the user already has a keyserver in their device list.
  2. I'll rename getForeignPeerDevices to getForeignPeerDeviceIDs in a new diff