Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3246291
D7453.id25238.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D7453.id25238.diff
View Options
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
@@ -870,6 +870,10 @@
name: threadInfo.name,
display: 'uiName',
uiName: memberEntities,
+ ifJustViewer:
+ threadInfo.type === threadTypes.PRIVATE
+ ? 'viewer_username'
+ : 'just_you_string',
};
}
diff --git a/lib/utils/entity-text.js b/lib/utils/entity-text.js
--- a/lib/utils/entity-text.js
+++ b/lib/utils/entity-text.js
@@ -34,6 +34,10 @@
// If uiName is EntityText, then at render time ThreadEntity will be
// replaced with a pluralized list of uiName's UserEntities
+uiName: $ReadOnlyArray<UserEntity> | string,
+ // If name isn't set and uiName is an array with only the viewer, then
+ // just_you_string displays "just you" but viewer_username displays the
+ // viewer's ENS-resolved username. Defaults to just_you_string
+ +ifJustViewer?: 'just_you_string' | 'viewer_username',
}
| {
+type: 'thread',
@@ -233,18 +237,29 @@
if (typeof uiName === 'string') {
return uiName;
}
+
let userEntities = uiName;
if (!params?.ignoreViewer) {
- userEntities = userEntities.filter(innerEntity => !innerEntity.isViewer);
- }
- if (userEntities.length === 0) {
- return 'just you';
+ const viewerFilteredUserEntities = userEntities.filter(
+ innerEntity => !innerEntity.isViewer,
+ );
+ if (viewerFilteredUserEntities.length > 0) {
+ userEntities = viewerFilteredUserEntities;
+ } else if (entity.ifJustViewer === 'viewer_username') {
+ // We pass ignoreViewer to entityTextToRawString in order
+ // to prevent it from rendering the viewer as "you"
+ params = { ...params, ignoreViewer: true };
+ } else {
+ return 'just you';
+ }
}
+
const pluralized = pluralizeEntityText(
userEntities.map(innerEntity => [innerEntity]),
);
return entityTextToRawString(pluralized, params);
}
+
invariant(
entity.display === 'shortName',
`getNameForThreadEntity can't handle thread entity display ${display}`,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 15, 10:34 PM (20 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2495693
Default Alt Text
D7453.id25238.diff (2 KB)
Attached To
Mode
D7453: [lib] Introduce new ifJustViewer field in ThreadEntity for PRIVATE threads
Attached
Detach File
Event Timeline
Log In to Comment