diff --git a/lib/shared/mention-utils.js b/lib/shared/mention-utils.js --- a/lib/shared/mention-utils.js +++ b/lib/shared/mention-utils.js @@ -11,6 +11,7 @@ import { type ThreadInfo, type RelativeMemberInfo, + type ResolvedThreadInfo, } from '../types/thread-types.js'; export type TypeaheadMatchedStrings = { @@ -28,7 +29,14 @@ +userInfo: RelativeMemberInfo, }; -export type MentionTypeaheadSuggestionItem = MentionTypeaheadUserSuggestionItem; +type MentionTypeaheadChatSuggestionItem = { + +type: 'chat', + +chat: ResolvedThreadInfo, +}; + +export type MentionTypeaheadSuggestionItem = + | MentionTypeaheadUserSuggestionItem + | MentionTypeaheadChatSuggestionItem; export type TypeaheadTooltipActionItem = { +key: string, diff --git a/native/chat/chat-input-bar.react.js b/native/chat/chat-input-bar.react.js --- a/native/chat/chat-input-bar.react.js +++ b/native/chat/chat-input-bar.react.js @@ -69,11 +69,11 @@ } from 'lib/types/message-types.js'; import type { Dispatch } from 'lib/types/redux-types.js'; import { threadPermissions } from 'lib/types/thread-permission-types.js'; -import { - type ThreadInfo, - type ClientThreadJoinRequest, - type ThreadJoinPayload, - type RelativeMemberInfo, +import type { + ThreadInfo, + ClientThreadJoinRequest, + ThreadJoinPayload, + RelativeMemberInfo, } from 'lib/types/thread-types.js'; import { type UserInfos } from 'lib/types/user-types.js'; import { diff --git a/native/utils/typeahead-utils.js b/native/utils/typeahead-utils.js --- a/native/utils/typeahead-utils.js +++ b/native/utils/typeahead-utils.js @@ -6,6 +6,7 @@ import { oldValidUsernameRegexString } from 'lib/shared/account-utils.js'; import { getNewTextAndSelection, + encodeChatMentionText, type Selection, type TypeaheadTooltipActionItem, type MentionTypeaheadSuggestionItem, @@ -65,6 +66,30 @@ userInfo, }, }); + } else if (suggestion.type === 'chat') { + const { chat } = suggestion; + const mentionText = `@[[${chat.id}:${encodeChatMentionText( + chat.uiName, + )}]]`; + actions.push({ + key: chat.id, + execute: () => { + const { newText, newSelectionStart } = getNewTextAndSelection( + textBeforeAtSymbol, + text, + textPrefix, + mentionText, + ); + focusAndUpdateTextAndSelection(newText, { + start: newSelectionStart, + end: newSelectionStart, + }); + }, + actionButtonContent: { + type: 'chat', + chat, + }, + }); } } return actions;