Page MenuHomePhabricator

[lib] Add hook for secondary device logout
ClosedPublic

Authored by bartek on May 28 2024, 4:21 AM.
Tags
None
Referenced Files
F3539026: D12221.diff
Thu, Dec 26, 12:03 AM
Unknown Object (File)
Mon, Dec 23, 4:01 PM
Unknown Object (File)
Mon, Dec 23, 4:00 PM
Unknown Object (File)
Mon, Dec 23, 4:00 PM
Unknown Object (File)
Mon, Dec 23, 4:00 PM
Unknown Object (File)
Mon, Dec 23, 4:00 PM
Unknown Object (File)
Nov 25 2024, 5:45 PM
Unknown Object (File)
Nov 25 2024, 1:24 PM
Subscribers

Details

Summary
  • Modified useLogOut() hook to be able to choose which identityClient method we want to call. Defaults to previous behavior
  • Added useSecondaryDeviceLogOut() hook which calls the previous one with the proper method. In future diffs, it will be updated to notify primary device

Depends on D12122

Test Plan
  • Made sure that identity logout still works as before and keyserver logout is triggered.
  • Made sure that setting logOutType: 'secondary_device' actually calls the other Identity RPC

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

bartek held this revision as a draft.
bartek published this revision for review.May 28 2024, 5:18 AM
bartek added inline comments.
lib/actions/user-actions.js
117 ↗(On Diff #40675)

Not sure about best naming here. In the future, there's also going to be a primary_device here

220–225 ↗(On Diff #40675)

In the future diffs, this is extended to notify primary device when logout is called

ashoat requested changes to this revision.May 28 2024, 12:27 PM

Minor comments, but I'd like to review it once more after revision

lib/actions/user-actions.js
117 ↗(On Diff #40675)

I'd call it legacy instead of identity, since we're planning on deprecating it after launching signed device lists

133–141 ↗(On Diff #40675)

There is no reason to memoize here. The calculation is cheap, and the resultant function isn't being regenerated on each invocation

221–223 ↗(On Diff #40675)

It's risky to generate a new object on each invocation here. The useLogOut hook appears to handle this safely, but in general when writing React code you should avoid instantiating new objects on every invocation of a function.

Instead, can we just pull out the object declaration to the top-level?

This revision now requires changes to proceed.May 28 2024, 12:27 PM
  • Renamed identity logout type to legacy
  • Got rid of useMemo
  • Made object declaration top-level
This revision is now accepted and ready to land.May 29 2024, 9:56 AM
This revision was automatically updated to reflect the committed changes.