Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3281761
D7402.id25051.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D7402.id25051.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D7402: [lib] introduce savedEmojiAvatarSelectorForCurrentUser selector
Attached
Detach File
Event Timeline
Log In to Comment