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
F2623044: D12809.id.diff
Fri, Sep 6, 9:50 PM
Unknown Object (File)
Tue, Sep 3, 7:52 PM
Unknown Object (File)
Fri, Aug 30, 1:36 AM
Unknown Object (File)
Tue, Aug 27, 8:24 PM
Unknown Object (File)
Mon, Aug 26, 1:11 PM
Unknown Object (File)
Mon, Aug 26, 5:57 AM
Unknown Object (File)
Mon, Aug 26, 2:41 AM
Unknown Object (File)
Sun, Aug 25, 3:25 AM
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