Page MenuHomePhabricator

D12603.diff
No OneTemporary

D12603.diff

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

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)

Event Timeline