Improve processing of mentions in direct conversations

Co-authored-by: trevor-signal <131492920+trevor-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2026-03-26 15:25:30 -05:00
committed by GitHub
parent ba64b9f945
commit cd2ea31c03
2 changed files with 12 additions and 2 deletions

View File

@@ -3,10 +3,12 @@
import type { ConversationAttributesType } from '../model-types.d.ts';
import type { DraftPreviewType } from '../state/ducks/conversations.preload.js';
import { BodyRange } from '../types/BodyRange.std.js';
import { findAndFormatContact } from './findAndFormatContact.preload.js';
import { hydrateRanges } from './BodyRange.node.js';
import { isVoiceMessage } from './Attachment.std.js';
import { stripNewlinesForLeftPane } from './stripNewlinesForLeftPane.std.js';
import { isDirectConversation } from './whatTypeOfConversation.dom.js';
const { i18n } = window.SignalContext;
@@ -16,7 +18,10 @@ export function getDraftPreview(
const { draft } = attributes;
const rawBodyRanges = attributes.draftBodyRanges || [];
const bodyRanges = hydrateRanges(rawBodyRanges, findAndFormatContact);
const bodyRangesToHydrate = isDirectConversation(attributes)
? rawBodyRanges.filter(range => !BodyRange.isMention(range))
: rawBodyRanges;
const bodyRanges = hydrateRanges(bodyRangesToHydrate, findAndFormatContact);
if (draft) {
return {

View File

@@ -4,12 +4,14 @@
import type { AciString } from '../types/ServiceId.std.js';
import type { ConversationAttributesType } from '../model-types.d.ts';
import type { LastMessageType } from '../state/ducks/conversations.preload.js';
import { BodyRange } from '../types/BodyRange.std.js';
import { dropNull } from './dropNull.std.js';
import { findAndFormatContact } from './findAndFormatContact.preload.js';
import { hydrateRanges } from './BodyRange.node.js';
import { stripNewlinesForLeftPane } from './stripNewlinesForLeftPane.std.js';
import { itemStorage } from '../textsecure/Storage.preload.js';
import { getTitle } from './getTitle.preload.js';
import { isDirectConversation } from './whatTypeOfConversation.dom.js';
function getNameForAci(
aci: AciString | null | undefined,
@@ -77,7 +79,10 @@ export function getLastMessage(
}
const rawBodyRanges = conversationAttrs.lastMessageBodyRanges || [];
const bodyRanges = hydrateRanges(rawBodyRanges, findAndFormatContact);
const bodyRangesToHydrate = isDirectConversation(conversationAttrs)
? rawBodyRanges.filter(range => !BodyRange.isMention(range))
: rawBodyRanges;
const bodyRanges = hydrateRanges(bodyRangesToHydrate, findAndFormatContact);
const text = stripNewlinesForLeftPane(lastMessageText);
const prefix = conversationAttrs.lastMessagePrefix;