Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/packages/socket/src/components/ChatView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -649,6 +649,7 @@ export const ChatView = memo(({
threadMetaById,
threadMessages,
messageMap,
mentionViewer.channelName,
currentUserId,
massViewer,
customEmojiList,
Expand Down Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions src/packages/socket/src/components/chatViewHelpers.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);
}

Expand Down
Loading