diff --git a/src/packages/socket/src/components/ChatView.tsx b/src/packages/socket/src/components/ChatView.tsx index 771c390f..c3f12c3e 100644 --- a/src/packages/socket/src/components/ChatView.tsx +++ b/src/packages/socket/src/components/ChatView.tsx @@ -618,7 +618,7 @@ export const ChatView = memo(({ message={m} meta={meta} replyPreviewText={ - m.reply_to_message_id ? getReplyPreview(replyOriginal ?? null, 100) : null + m.reply_to_message_id ? getReplyPreview(replyOriginal ?? null, 100, mentionViewer.channelName) : null } isMentioned={mentionsViewer(m, currentUserId, massViewer)} customEmojiList={customEmojiList} @@ -649,6 +649,7 @@ export const ChatView = memo(({ threadMetaById, threadMessages, messageMap, + mentionViewer.channelName, currentUserId, massViewer, customEmojiList, @@ -848,7 +849,7 @@ export const ChatView = memo(({ const replyOriginal = m.reply_to_message_id ? messageMap.get(m.reply_to_message_id) ?? m.reply_original : undefined; - const replyPreviewText = m.reply_to_message_id ? getReplyPreview(replyOriginal ?? null, 100) : null; + const replyPreviewText = m.reply_to_message_id ? getReplyPreview(replyOriginal ?? null, 100, mentionViewer.channelName) : null; const isMentioned = mentionsViewer(m, currentUserId, massViewer); /* Your own send is drawn at once and swapped for the server's copy, with a new id diff --git a/src/packages/socket/src/components/chatViewHelpers.ts b/src/packages/socket/src/components/chatViewHelpers.ts index f799396c..1788561d 100644 --- a/src/packages/socket/src/components/chatViewHelpers.ts +++ b/src/packages/socket/src/components/chatViewHelpers.ts @@ -1,3 +1,6 @@ +import { toPlainNotificationText } from "@/lib/desktopNotification"; +import type { ChannelName } from "@/lib/mentionTokens"; + import { nameTagsFor } from "../../../lib/nameTags.ts"; import type { ChatMessage } from "./chatUtils"; import { toDate } from "./chatUtils"; @@ -17,9 +20,11 @@ export function getAttachmentPreview(msg: ChatMessage): string { return "Attachment"; } -export function getReplyPreview(msg: ChatMessage | null | undefined, maxLen: number): string { +/** One line of what a reply answers, as words: mentions read as @name, and markdown is gone. */ +export function getReplyPreview(msg: ChatMessage | null | undefined, maxLen: number, channelName?: ChannelName): string { if (!msg) return "Original message"; - if (msg.text) return msg.text.length > maxLen ? msg.text.slice(0, maxLen) + "..." : msg.text; + const text = msg.text ? toPlainNotificationText(msg.text, channelName) : ""; + if (text) return text.length > maxLen ? text.slice(0, maxLen) + "..." : text; return getAttachmentPreview(msg); }