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 @@ -10,6 +10,10 @@ UpdateUserSettingsRequest, PolicyAcknowledgmentRequest, } from '../types/account-types.js'; +import type { + ClientAvatar, + UpdateUserAvatarRequest, +} from '../types/avatar-types.js'; import type { GetSessionPublicKeysArgs } from '../types/request-types.js'; import type { UserSearchResult } from '../types/search-types.js'; import type { @@ -244,6 +248,19 @@ await callServerEndpoint('policy_acknowledgment', policyRequest); }; +const updateUserAvatarActionTypes = Object.freeze({ + started: 'UPDATE_USER_AVATAR_STARTED', + success: 'UPDATE_USER_AVATAR_SUCCESS', + failed: 'UPDATE_USER_AVATAR_FAILED', +}); +const updateUserAvatar = + ( + callServerEndpoint: CallServerEndpoint, + ): ((avatarDBContent: UpdateUserAvatarRequest) => Promise) => + async avatarDBContent => { + return await callServerEndpoint('update_user_avatar', avatarDBContent); + }; + export { changeUserPasswordActionTypes, changeUserPassword, @@ -265,4 +282,6 @@ updateSubscriptionActionTypes, policyAcknowledgment, policyAcknowledgmentActionTypes, + updateUserAvatarActionTypes, + updateUserAvatar, }; 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 @@ -12,6 +12,7 @@ QueueActivityUpdatesPayload, SetThreadUnreadStatusPayload, } from './activity-types.js'; +import type { ClientAvatar, UpdateUserAvatarRequest } from './avatar-types.js'; import type { CryptoStore } from './crypto-types.js'; import type { ClientDBDraftInfo, DraftStore } from './draft-types.js'; import type { EnabledApps, SupportedApps } from './enabled-apps.js'; @@ -917,6 +918,22 @@ | { +type: 'RECORD_NOTIF_PERMISSION_ALERT', +payload: { +time: number }, + } + | { + +type: 'UPDATE_USER_AVATAR_STARTED', + +payload: UpdateUserAvatarRequest, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_USER_AVATAR_SUCCESS', + +payload: ?ClientAvatar, + +loadingInfo: LoadingInfo, + } + | { + +type: 'UPDATE_USER_AVATAR_FAILED', + +error: true, + +payload: Error, + +loadingInfo: LoadingInfo, }; export type ActionPayload = ?(Object | Array<*> | $ReadOnlyArray<*> | string);