Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32645908
D7402.1767508492.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D7402.1767508492.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,21 @@
},
);
+const savedEmojiAvatarSelectorForCurrentUser: (
+ state: BaseAppState<*>,
+) => () => ClientEmojiAvatar = createSelector(
+ (state: BaseAppState<*>) => state.currentUserInfo && state.currentUserInfo,
+ (currentUser: ?CurrentUserInfo) => {
+ return () => {
+ let userAvatar = getAvatarForUser(currentUser);
+ if (userAvatar.type !== 'emoji') {
+ userAvatar = getRandomDefaultEmojiAvatar();
+ }
+ return userAvatar;
+ };
+ },
+);
+
export {
userIDsToRelativeUserInfos,
getRelativeMemberInfos,
@@ -214,4 +235,5 @@
isLoggedIn,
userStoreSearchIndex,
usersWithPersonalThreadSelector,
+ savedEmojiAvatarSelectorForCurrentUser,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 4, 6:34 AM (1 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5889630
Default Alt Text
D7402.1767508492.diff (1 KB)
Attached To
Mode
D7402: [lib] introduce savedEmojiAvatarSelectorForCurrentUser selector
Attached
Detach File
Event Timeline
Log In to Comment