Page MenuHomePhabricator

D7700.id25994.diff
No OneTemporary

D7700.id25994.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
@@ -11,8 +11,8 @@
PolicyAcknowledgmentRequest,
} from '../types/account-types.js';
import type {
- ClientAvatar,
UpdateUserAvatarRequest,
+ UpdateUserAvatarResponse,
} from '../types/avatar-types.js';
import type { GetSessionPublicKeysArgs } from '../types/request-types.js';
import type { UserSearchResult } from '../types/search-types.js';
@@ -256,9 +256,15 @@
const updateUserAvatar =
(
callServerEndpoint: CallServerEndpoint,
- ): ((avatarDBContent: UpdateUserAvatarRequest) => Promise<?ClientAvatar>) =>
+ ): ((
+ avatarDBContent: UpdateUserAvatarRequest,
+ ) => Promise<UpdateUserAvatarResponse>) =>
async avatarDBContent => {
- return await callServerEndpoint('update_user_avatar', avatarDBContent);
+ const { updates }: UpdateUserAvatarResponse = await callServerEndpoint(
+ 'update_user_avatar',
+ avatarDBContent,
+ );
+ return { updates };
};
export {
diff --git a/lib/reducers/user-reducer.js b/lib/reducers/user-reducer.js
--- a/lib/reducers/user-reducer.js
+++ b/lib/reducers/user-reducer.js
@@ -99,10 +99,19 @@
state &&
!state.anonymous
) {
- return {
- ...state,
- avatar: action.payload,
- };
+ const { viewerUpdates } = action.payload.updates;
+ for (const update of viewerUpdates) {
+ if (
+ update.type === updateTypes.UPDATE_CURRENT_USER &&
+ !_isEqual(update.currentUserInfo.avatar)(state.avatar)
+ ) {
+ return {
+ ...state,
+ avatar: update.currentUserInfo.avatar,
+ };
+ }
+ }
+ return state;
} else if (action.type === setUserSettingsActionTypes.success) {
if (state?.settings) {
return {
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,7 +12,10 @@
QueueActivityUpdatesPayload,
SetThreadUnreadStatusPayload,
} from './activity-types.js';
-import type { ClientAvatar, UpdateUserAvatarRequest } from './avatar-types.js';
+import type {
+ UpdateUserAvatarRequest,
+ UpdateUserAvatarResponse,
+} 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';
@@ -933,7 +936,7 @@
}
| {
+type: 'UPDATE_USER_AVATAR_SUCCESS',
- +payload: ?ClientAvatar,
+ +payload: UpdateUserAvatarResponse,
+loadingInfo: LoadingInfo,
}
| {

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 10:33 AM (21 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2611345
Default Alt Text
D7700.id25994.diff (2 KB)

Event Timeline