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 @@ -91,6 +91,7 @@ import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js'; import { getConfig } from '../utils/config.js'; import { getMessageForException } from '../utils/errors.js'; +import { useDispatchActionPromise } from '../utils/redux-promise-utils.js'; import { useSelector } from '../utils/redux-utils.js'; import { usingCommServicesAccessToken } from '../utils/services-utils.js'; import sleep from '../utils/sleep.js'; @@ -267,6 +268,39 @@ }, [commServicesAccessToken, identityClient, preRequestUserState]); } +function useInvalidCSATLogOut(): () => Promise { + const dispatchActionPromise = useDispatchActionPromise(); + + const preRequestUserState = usePreRequestUserState(); + const callKeyserverLogOut = useKeyserverCall(keyserverLogOut); + + const commServicesAccessToken = useSelector( + state => state.commServicesAccessToken, + ); + + return React.useCallback(() => { + const keyserverLogOutPromise = async () => { + console.log('wylogowuje'); + const { keyserverIDs: _, ...result } = await callKeyserverLogOut({ + preRequestUserState, + }); + return { + ...result, + preRequestUserState: { + ...result.preRequestUserState, + commServicesAccessToken, + }, + }; + }; + return dispatchActionPromise(logOutActionTypes, keyserverLogOutPromise()); + }, [ + dispatchActionPromise, + commServicesAccessToken, + callKeyserverLogOut, + preRequestUserState, + ]); +} + const primaryDeviceLogOutOptions = Object.freeze({ logOutType: 'primary_device', }); @@ -1449,4 +1483,5 @@ processNewUserIDsActionType, versionSupportedByIdentityActionTypes, useVersionSupportedByIdentity, + useInvalidCSATLogOut, };