Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3341744
D12603.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12603.diff
View Options
diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -133,7 +133,7 @@
};
type UseLogOutOptions = {
- +logOutType?: 'legacy' | 'secondary_device',
+ +logOutType?: 'legacy' | 'primary_device' | 'secondary_device',
};
function useLogOut(
@@ -159,10 +159,21 @@
if (!identityClient) {
throw new Error('Identity service client is not initialized');
}
- const callIdentityClientLogOut =
- logOutType === 'secondary_device'
- ? identityClient.logOutSecondaryDevice
- : identityClient.logOut;
+ let callIdentityClientLogOut;
+ if (logOutType === 'primary_device') {
+ if (!identityClient.logOutPrimaryDevice) {
+ throw new Error(
+ 'logOutPrimaryDevice not defined. ' +
+ 'Are you calling it on non-primary device?',
+ );
+ }
+ callIdentityClientLogOut = identityClient.logOutPrimaryDevice;
+ } else {
+ callIdentityClientLogOut =
+ logOutType === 'secondary_device'
+ ? identityClient.logOutSecondaryDevice
+ : identityClient.logOut;
+ }
try {
await Promise.race([
callIdentityClientLogOut(),
@@ -235,6 +246,15 @@
}, [commServicesAccessToken, identityClient, preRequestUserState]);
}
+const primaryDeviceLogOutOptions = Object.freeze({
+ logOutType: 'primary_device',
+});
+
+function usePrimaryDeviceLogOut(): () => Promise<LogOutResult> {
+ const logOut = useLogOut(primaryDeviceLogOutOptions);
+ return logOut;
+}
+
const secondaryDeviceLogOutOptions = Object.freeze({
logOutType: 'secondary_device',
});
@@ -1301,6 +1321,7 @@
legacyLogInActionTypes,
useLogOut,
useIdentityLogOut,
+ usePrimaryDeviceLogOut,
useSecondaryDeviceLogOut,
logOutActionTypes,
legacyKeyserverRegister,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 11:36 PM (11 h, 42 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2566581
Default Alt Text
D12603.diff (1 KB)
Attached To
Mode
D12603: [lib] Add usePrimaryDeviceLogOut hook
Attached
Detach File
Event Timeline
Log In to Comment