Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33309100
D7453.1768803766.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D7453.1768803766.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
Mon, Jan 19, 6:22 AM (10 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5954821
Default Alt Text
D7453.1768803766.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