Skip to content

Commit 332f19a

Browse files
authored
Fix reply/quoting breaking for poll messages
1 parent c6a79d2 commit 332f19a

File tree

5 files changed

+35
-9
lines changed

5 files changed

+35
-9
lines changed

_locales/en/messages.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,10 @@
30763076
"messageformat": "Poll: {pollQuestion}",
30773077
"description": "Shown in notifications and in the left pane when a poll message is received. {pollQuestion} is the poll question text."
30783078
},
3079+
"icu:Poll--preview": {
3080+
"messageformat": "Poll: {pollQuestion}",
3081+
"description": "Shown in notifications, the left pane message preview, and quotes when a poll message is referenced."
3082+
},
30793083
"icu:message--getNotificationText--text-with-emoji": {
30803084
"messageformat": "{emoji} {text}",
30813085
"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."

ts/messages/copyQuote.preload.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { isDownloadable } from '../util/Attachment.std.js';
2424
const { omit } = lodash;
2525

2626
const log = createLogger('copyQuote');
27+
const { i18n } = window.SignalContext;
2728

2829
export type MinimalMessageCache = Readonly<{
2930
findBySentAt(
@@ -129,7 +130,11 @@ export const copyQuoteContentFromOriginal = async (
129130
quote.isViewOnce = false;
130131

131132
// eslint-disable-next-line no-param-reassign
132-
quote.text = getQuoteBodyText(message.attributes, quote.id);
133+
quote.text = getQuoteBodyText({
134+
messageAttributes: message.attributes,
135+
id: quote.id,
136+
i18n,
137+
});
133138

134139
// eslint-disable-next-line no-param-reassign
135140
quote.bodyRanges = message.attributes.bodyRanges;

ts/util/getNotificationDataForMessage.preload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ export function getNotificationDataForMessage(
514514
if (poll) {
515515
return {
516516
emoji: '📊',
517-
text: i18n('icu:message--getNotificationText--poll', {
517+
text: i18n('icu:Poll--preview', {
518518
pollQuestion: poll.question,
519519
}),
520520
bodyRanges,

ts/util/getQuoteBodyText.std.ts

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
// SPDX-License-Identifier: AGPL-3.0-only
33

44
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
5+
import type { LocalizerType } from '../types/Util.std.js';
56
import * as EmbeddedContact from '../types/EmbeddedContact.std.js';
67

7-
export function getQuoteBodyText(
8-
messageAttributes: ReadonlyMessageAttributesType,
9-
id: number | null
10-
): string | undefined {
8+
export function getQuoteBodyText({
9+
messageAttributes,
10+
id,
11+
i18n,
12+
}: {
13+
messageAttributes: ReadonlyMessageAttributesType;
14+
id: number | null;
15+
i18n: LocalizerType;
16+
}): string | undefined {
1117
const storyReactionEmoji = messageAttributes.storyReaction?.emoji;
1218

1319
if (id != null) {
@@ -20,11 +26,17 @@ export function getQuoteBodyText(
2026
}
2127
}
2228

23-
const { body, contact: embeddedContact } = messageAttributes;
29+
const { body, contact: embeddedContact, poll } = messageAttributes;
2430
const embeddedContactName =
2531
embeddedContact && embeddedContact.length > 0
2632
? EmbeddedContact.getName(embeddedContact[0])
2733
: '';
2834

29-
return body || embeddedContactName || storyReactionEmoji;
35+
const pollText = poll
36+
? i18n('icu:Poll--preview', {
37+
pollQuestion: poll.question,
38+
})
39+
: undefined;
40+
41+
return body || embeddedContactName || pollText || storyReactionEmoji;
3042
}

ts/util/makeQuote.preload.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { getLocalAttachmentUrl } from './getLocalAttachmentUrl.std.js';
2525
import type { QuotedMessageForComposerType } from '../state/ducks/composer.preload.js';
2626

2727
const log = createLogger('makeQuote');
28+
const { i18n } = window.SignalContext;
2829

2930
export async function makeQuote(
3031
quotedMessage: MessageAttributesType
@@ -56,7 +57,11 @@ export async function makeQuote(
5657
isGiftBadge: isGiftBadge(quotedMessage),
5758
messageId,
5859
referencedMessageNotFound: false,
59-
text: getQuoteBodyText(quotedMessage, quoteId),
60+
text: getQuoteBodyText({
61+
messageAttributes: quotedMessage,
62+
id: quoteId,
63+
i18n,
64+
}),
6065
};
6166
}
6267

0 commit comments

Comments
 (0)