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 @@ -18,6 +18,7 @@ UpdateUserAvatarResponse, } from '../types/avatar-types.js'; import type { RawEntryInfo, CalendarQuery } from '../types/entry-types.js'; +import type { IdentityServiceClient } from '../types/identity-service-types'; import type { RawMessageInfo, MessageTruncationStatuses, @@ -149,6 +150,24 @@ return useKeyserverCall(deleteKeyserverAccount); } +const deleteIdentityAccountActionTypes = Object.freeze({ + started: 'DELETE_IDENTITY_ACCOUNT_STARTED', + success: 'DELETE_IDENTITY_ACCOUNT_SUCCESS', + failed: 'DELETE_IDENTITY_ACCOUNT_FAILED', +}); + +const deleteIdentityAccount = async ( + client: IdentityServiceClient, +): Promise => { + await client.deleteUser(); +}; + +function useDeleteIdentityAccount( + client: IdentityServiceClient, +): () => Promise { + return () => deleteIdentityAccount(client); +} + const registerActionTypes = Object.freeze({ started: 'REGISTER_STARTED', success: 'REGISTER_SUCCESS', @@ -526,4 +545,6 @@ updateUserAvatar, resetUserStateActionType, setAccessTokenActionType, + deleteIdentityAccountActionTypes, + useDeleteIdentityAccount, }; diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js --- a/lib/types/identity-service-types.js +++ b/lib/types/identity-service-types.js @@ -18,3 +18,7 @@ +oneTimeContentPrekey: ?string, +oneTimeNotifPrekey: ?string, }; + +export interface IdentityServiceClient { + deleteUser(): Promise; +} diff --git a/lib/types/redux-types.js b/lib/types/redux-types.js --- a/lib/types/redux-types.js +++ b/lib/types/redux-types.js @@ -229,6 +229,22 @@ +payload: LogOutResult, +loadingInfo: LoadingInfo, } + | { + +type: 'DELETE_IDENTITY_ACCOUNT_STARTED', + +payload?: void, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_IDENTITY_ACCOUNT_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, + } + | { + +type: 'DELETE_IDENTITY_ACCOUNT_SUCCESS', + +payload: void, + +loadingInfo: LoadingInfo, + } | { +type: 'CREATE_LOCAL_ENTRY', +payload: RawEntryInfo,