Page MenuHomePhabricator

D7402.id25051.diff
No OneTemporary

D7402.id25051.diff

diff --git a/lib/selectors/user-selectors.js b/lib/selectors/user-selectors.js
--- a/lib/selectors/user-selectors.js
+++ b/lib/selectors/user-selectors.js
@@ -3,11 +3,16 @@
import _memoize from 'lodash/memoize.js';
import { createSelector } from 'reselect';
+import {
+ getAvatarForUser,
+ getRandomDefaultEmojiAvatar,
+} from '../shared/avatar-utils.js';
import SearchIndex from '../shared/search-index.js';
import {
getSingleOtherUser,
memberHasAdminPowers,
} from '../shared/thread-utils.js';
+import type { ClientEmojiAvatar } from '../types/avatar-types';
import type { BaseAppState } from '../types/redux-types.js';
import { userRelationshipStatus } from '../types/relationship-types.js';
import {
@@ -19,6 +24,7 @@
UserInfos,
RelativeUserInfo,
AccountUserInfo,
+ CurrentUserInfo,
} from '../types/user-types.js';
// Used for specific message payloads that include an array of user IDs, ie.
@@ -205,6 +211,19 @@
},
);
+const savedEmojiAvatarSelectorForCurrentUser: (
+ state: BaseAppState<*>,
+) => ClientEmojiAvatar = createSelector(
+ (state: BaseAppState<*>) => state.currentUserInfo && state.currentUserInfo,
+ (currentUser: ?CurrentUserInfo) => {
+ let userAvatar = getAvatarForUser(currentUser);
+ if (userAvatar.type !== 'emoji') {
+ userAvatar = getRandomDefaultEmojiAvatar();
+ }
+ return userAvatar;
+ },
+);
+
export {
userIDsToRelativeUserInfos,
getRelativeMemberInfos,
@@ -214,4 +233,5 @@
isLoggedIn,
userStoreSearchIndex,
usersWithPersonalThreadSelector,
+ savedEmojiAvatarSelectorForCurrentUser,
};

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 17, 10:11 AM (17 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2522141
Default Alt Text
D7402.id25051.diff (1 KB)

Event Timeline