Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3343755
D13462.id44624.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13462.id44624.diff
View Options
diff --git a/lib/shared/avatar-utils.js b/lib/shared/avatar-utils.js
--- a/lib/shared/avatar-utils.js
+++ b/lib/shared/avatar-utils.js
@@ -4,12 +4,12 @@
import * as React from 'react';
import stringHash from 'string-hash';
+import { getETHAddressForUserInfo } from './account-utils.js';
import { selectedThreadColors } from './color-utils.js';
import { threadOtherMembers } from './thread-utils.js';
import genesis from '../facts/genesis.js';
import { useENSAvatar } from '../hooks/ens-cache.js';
import { useFarcasterAvatarURL } from '../hooks/fc-cache.js';
-import { getETHAddressForUserInfo } from '../shared/account-utils.js';
import type {
ClientAvatar,
ClientEmojiAvatar,
@@ -19,7 +19,10 @@
ThreadInfo,
RawThreadInfo,
} from '../types/minimally-encoded-thread-permissions-types.js';
-import { threadTypes } from '../types/thread-types-enum.js';
+import {
+ threadTypeIsPersonal,
+ threadTypeIsPrivate,
+} from '../types/thread-types-enum.js';
import type { UserInfos } from '../types/user-types.js';
const defaultAnonymousUserEmojiAvatar: ClientEmojiAvatar = {
@@ -278,18 +281,18 @@
viewerID: ?string,
userInfos: UserInfos,
): ClientAvatar {
- if (threadInfo.type === threadTypes.GENESIS_PRIVATE) {
- invariant(viewerID, 'viewerID should be set for GENESIS_PRIVATE threads');
+ if (threadTypeIsPrivate(threadInfo.type)) {
+ invariant(viewerID, 'viewerID should be set for private threads');
return getAvatarForUser(userInfos[viewerID]);
}
invariant(
- threadInfo.type === threadTypes.GENESIS_PERSONAL,
- 'threadInfo should be a GENESIS_PERSONAL type',
+ threadTypeIsPersonal(threadInfo.type),
+ 'threadInfo should be personal',
);
const memberInfos = threadOtherMembers(threadInfo.members, viewerID)
- .map(member => userInfos[member.id] && userInfos[member.id])
+ .map(member => userInfos[member.id])
.filter(Boolean);
if (memberInfos.length === 0) {
diff --git a/lib/shared/thread-utils.js b/lib/shared/thread-utils.js
--- a/lib/shared/thread-utils.js
+++ b/lib/shared/thread-utils.js
@@ -79,6 +79,8 @@
assertThinThreadType,
assertThickThreadType,
threadTypeIsSidebar,
+ threadTypeIsPrivate,
+ threadTypeIsPersonal,
} from '../types/thread-types-enum.js';
import type {
LegacyRawThreadInfo,
@@ -1004,8 +1006,8 @@
if (avatar) {
threadInfo = { ...threadInfo, avatar };
} else if (
- rawThreadInfo.type === threadTypes.GENESIS_PERSONAL ||
- rawThreadInfo.type === threadTypes.GENESIS_PRIVATE
+ threadTypeIsPrivate(rawThreadInfo.type) ||
+ threadTypeIsPersonal(rawThreadInfo.type)
) {
threadInfo = {
...threadInfo,
diff --git a/native/avatars/thread-avatar.react.js b/native/avatars/thread-avatar.react.js
--- a/native/avatars/thread-avatar.react.js
+++ b/native/avatars/thread-avatar.react.js
@@ -11,7 +11,10 @@
ResolvedThreadInfo,
RawThreadInfo,
} from 'lib/types/minimally-encoded-thread-permissions-types.js';
-import { threadTypes } from 'lib/types/thread-types-enum.js';
+import {
+ threadTypeIsPersonal,
+ threadTypeIsPrivate,
+} from 'lib/types/thread-types-enum.js';
import Avatar from './avatar.react.js';
import { useSelector } from '../redux/redux-utils.js';
@@ -31,9 +34,9 @@
);
let displayUserIDForThread;
- if (threadInfo.type === threadTypes.GENESIS_PRIVATE) {
+ if (threadTypeIsPrivate(threadInfo.type)) {
displayUserIDForThread = viewerID;
- } else if (threadInfo.type === threadTypes.GENESIS_PERSONAL) {
+ } else if (threadTypeIsPersonal(threadInfo.type)) {
displayUserIDForThread = getSingleOtherUser(threadInfo, viewerID);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 23, 4:00 AM (18 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2565440
Default Alt Text
D13462.id44624.diff (3 KB)
Attached To
Mode
D13462: [lib] Update thick thread avatars logic
Attached
Detach File
Event Timeline
Log In to Comment