Page MenuHomePhabricator

[lib] Add hook for secondary device logout
ClosedPublic

Authored by bartek on May 28 2024, 4:21 AM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 11, 9:42 AM
Unknown Object (File)
Mon, Nov 11, 8:46 AM
Unknown Object (File)
Mon, Nov 11, 5:31 AM
Unknown Object (File)
Sun, Nov 10, 10:07 PM
Unknown Object (File)
Fri, Nov 8, 4:06 AM
Unknown Object (File)
Sat, Nov 2, 12:33 AM
Unknown Object (File)
Fri, Nov 1, 11:01 PM
Unknown Object (File)
Sun, Oct 27, 1:36 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
No Lint Coverage
Unit
No Test Coverage

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

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

220–225

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

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

133–141

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

221–223

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.