Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3251474
D6805.id22842.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
D6805.id22842.diff
View Options
diff --git a/lib/shared/messages/text-message-spec.js b/lib/shared/messages/text-message-spec.js
--- a/lib/shared/messages/text-message-spec.js
+++ b/lib/shared/messages/text-message-spec.js
@@ -38,7 +38,10 @@
stripSpoilersFromNotifications,
stripSpoilersFromMarkdownAST,
} from '../markdown.js';
-import { threadIsGroupChat, extractMentionedMembers } from '../thread-utils.js';
+import {
+ threadIsGroupChat,
+ extractNewMentionedParentMembers,
+} from '../thread-utils.js';
/**
* most of the markdown leaves contain `content` field
@@ -231,28 +234,20 @@
}
invariant(parentThreadInfo, 'all sidebars should have a parent thread');
- const mentionedMembersOfParent = extractMentionedMembers(
+ const mentionedNewMembers = extractNewMentionedParentMembers(
messageInfo.text,
+ threadInfo,
parentThreadInfo,
);
- if (mentionedMembersOfParent.size === 0) {
- return;
- }
-
- for (const member of threadInfo.members) {
- if (member.role) {
- mentionedMembersOfParent.delete(member.id);
- }
- }
- const mentionedToAdd = [...mentionedMembersOfParent.keys()];
- if (mentionedToAdd.length === 0) {
+ if (mentionedNewMembers.length === 0) {
return;
}
+ const newMemberIDs = mentionedNewMembers.map(({ id }) => id);
const addMembersPromise = callChangeThreadSettings({
threadID: threadInfo.id,
- changes: { newMemberIDs: mentionedToAdd },
+ changes: { newMemberIDs },
});
dispatchActionPromise(changeThreadSettingsActionTypes, addMembersPromise);
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
@@ -478,6 +478,25 @@
return mentionedMembers;
}
+// When a member of the parent is mentioned in a sidebar,
+// they will be automatically added to that sidebar
+function extractNewMentionedParentMembers(
+ messageText: string,
+ threadInfo: ThreadInfo,
+ parentThreadInfo: ThreadInfo,
+): AccountUserInfo[] {
+ const mentionedMembersOfParent = extractMentionedMembers(
+ messageText,
+ parentThreadInfo,
+ );
+ for (const member of threadInfo.members) {
+ if (member.role) {
+ mentionedMembersOfParent.delete(member.id);
+ }
+ }
+ return [...mentionedMembersOfParent.values()];
+}
+
type SharedCreatePendingSidebarInput = {
+sourceMessageInfo: ComposableMessageInfo | RobotextMessageInfo,
+parentThreadInfo: ThreadInfo,
@@ -1554,7 +1573,7 @@
parsePendingThreadID,
createPendingThread,
createUnresolvedPendingSidebar,
- extractMentionedMembers,
+ extractNewMentionedParentMembers,
createPendingSidebar,
pendingThreadType,
createRealThreadFromPendingThread,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Nov 16, 5:35 PM (22 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2498110
Default Alt Text
D6805.id22842.diff (2 KB)
Attached To
Mode
D6805: [lib] Factor out extractNewMentionedParentMembers
Attached
Detach File
Event Timeline
Log In to Comment