diff --git a/_locales/en/messages.json b/_locales/en/messages.json index cea613675c..654f789524 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -3076,6 +3076,10 @@ "messageformat": "Poll: {pollQuestion}", "description": "Shown in notifications and in the left pane when a poll message is received. {pollQuestion} is the poll question text." }, + "icu:Poll--preview": { + "messageformat": "Poll: {pollQuestion}", + "description": "Shown in notifications, the left pane message preview, and quotes when a poll message is referenced." + }, "icu:message--getNotificationText--text-with-emoji": { "messageformat": "{emoji} {text}", "description": "Shown in notifications and in the left pane when text has an emoji. Probably always [emoji] [text] on LTR languages and [text] [emoji] on RTL languages." diff --git a/ts/messages/copyQuote.preload.ts b/ts/messages/copyQuote.preload.ts index 229da0b15a..a65b2deaed 100644 --- a/ts/messages/copyQuote.preload.ts +++ b/ts/messages/copyQuote.preload.ts @@ -24,6 +24,7 @@ import { isDownloadable } from '../util/Attachment.std.js'; const { omit } = lodash; const log = createLogger('copyQuote'); +const { i18n } = window.SignalContext; export type MinimalMessageCache = Readonly<{ findBySentAt( @@ -129,7 +130,11 @@ export const copyQuoteContentFromOriginal = async ( quote.isViewOnce = false; // eslint-disable-next-line no-param-reassign - quote.text = getQuoteBodyText(message.attributes, quote.id); + quote.text = getQuoteBodyText({ + messageAttributes: message.attributes, + id: quote.id, + i18n, + }); // eslint-disable-next-line no-param-reassign quote.bodyRanges = message.attributes.bodyRanges; diff --git a/ts/util/getNotificationDataForMessage.preload.ts b/ts/util/getNotificationDataForMessage.preload.ts index acaa217e2e..6b181cab73 100644 --- a/ts/util/getNotificationDataForMessage.preload.ts +++ b/ts/util/getNotificationDataForMessage.preload.ts @@ -514,7 +514,7 @@ export function getNotificationDataForMessage( if (poll) { return { emoji: '📊', - text: i18n('icu:message--getNotificationText--poll', { + text: i18n('icu:Poll--preview', { pollQuestion: poll.question, }), bodyRanges, diff --git a/ts/util/getQuoteBodyText.std.ts b/ts/util/getQuoteBodyText.std.ts index f640100ca9..fea5307ee3 100644 --- a/ts/util/getQuoteBodyText.std.ts +++ b/ts/util/getQuoteBodyText.std.ts @@ -2,12 +2,18 @@ // SPDX-License-Identifier: AGPL-3.0-only import type { ReadonlyMessageAttributesType } from '../model-types.d.ts'; +import type { LocalizerType } from '../types/Util.std.js'; import * as EmbeddedContact from '../types/EmbeddedContact.std.js'; -export function getQuoteBodyText( - messageAttributes: ReadonlyMessageAttributesType, - id: number | null -): string | undefined { +export function getQuoteBodyText({ + messageAttributes, + id, + i18n, +}: { + messageAttributes: ReadonlyMessageAttributesType; + id: number | null; + i18n: LocalizerType; +}): string | undefined { const storyReactionEmoji = messageAttributes.storyReaction?.emoji; if (id != null) { @@ -20,11 +26,17 @@ export function getQuoteBodyText( } } - const { body, contact: embeddedContact } = messageAttributes; + const { body, contact: embeddedContact, poll } = messageAttributes; const embeddedContactName = embeddedContact && embeddedContact.length > 0 ? EmbeddedContact.getName(embeddedContact[0]) : ''; - return body || embeddedContactName || storyReactionEmoji; + const pollText = poll + ? i18n('icu:Poll--preview', { + pollQuestion: poll.question, + }) + : undefined; + + return body || embeddedContactName || pollText || storyReactionEmoji; } diff --git a/ts/util/makeQuote.preload.ts b/ts/util/makeQuote.preload.ts index 58bd55ed64..5d355ec38d 100644 --- a/ts/util/makeQuote.preload.ts +++ b/ts/util/makeQuote.preload.ts @@ -25,6 +25,7 @@ import { getLocalAttachmentUrl } from './getLocalAttachmentUrl.std.js'; import type { QuotedMessageForComposerType } from '../state/ducks/composer.preload.js'; const log = createLogger('makeQuote'); +const { i18n } = window.SignalContext; export async function makeQuote( quotedMessage: MessageAttributesType @@ -56,7 +57,11 @@ export async function makeQuote( isGiftBadge: isGiftBadge(quotedMessage), messageId, referencedMessageNotFound: false, - text: getQuoteBodyText(quotedMessage, quoteId), + text: getQuoteBodyText({ + messageAttributes: quotedMessage, + id: quoteId, + i18n, + }), }; }