mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-20 02:08:57 +00:00
Fix reply/quoting breaking for poll messages
Co-authored-by: yash-signal <yash@signal.org>
This commit is contained in:
@@ -3076,6 +3076,10 @@
|
|||||||
"messageformat": "Poll: {pollQuestion}",
|
"messageformat": "Poll: {pollQuestion}",
|
||||||
"description": "Shown in notifications and in the left pane when a poll message is received. {pollQuestion} is the poll question text."
|
"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": {
|
"icu:message--getNotificationText--text-with-emoji": {
|
||||||
"messageformat": "{emoji} {text}",
|
"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."
|
"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."
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import { isDownloadable } from '../util/Attachment.std.js';
|
|||||||
const { omit } = lodash;
|
const { omit } = lodash;
|
||||||
|
|
||||||
const log = createLogger('copyQuote');
|
const log = createLogger('copyQuote');
|
||||||
|
const { i18n } = window.SignalContext;
|
||||||
|
|
||||||
export type MinimalMessageCache = Readonly<{
|
export type MinimalMessageCache = Readonly<{
|
||||||
findBySentAt(
|
findBySentAt(
|
||||||
@@ -129,7 +130,11 @@ export const copyQuoteContentFromOriginal = async (
|
|||||||
quote.isViewOnce = false;
|
quote.isViewOnce = false;
|
||||||
|
|
||||||
// eslint-disable-next-line no-param-reassign
|
// 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
|
// eslint-disable-next-line no-param-reassign
|
||||||
quote.bodyRanges = message.attributes.bodyRanges;
|
quote.bodyRanges = message.attributes.bodyRanges;
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ export function getNotificationDataForMessage(
|
|||||||
if (poll) {
|
if (poll) {
|
||||||
return {
|
return {
|
||||||
emoji: '📊',
|
emoji: '📊',
|
||||||
text: i18n('icu:message--getNotificationText--poll', {
|
text: i18n('icu:Poll--preview', {
|
||||||
pollQuestion: poll.question,
|
pollQuestion: poll.question,
|
||||||
}),
|
}),
|
||||||
bodyRanges,
|
bodyRanges,
|
||||||
|
|||||||
@@ -2,12 +2,18 @@
|
|||||||
// SPDX-License-Identifier: AGPL-3.0-only
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
|
import type { ReadonlyMessageAttributesType } from '../model-types.d.ts';
|
||||||
|
import type { LocalizerType } from '../types/Util.std.js';
|
||||||
import * as EmbeddedContact from '../types/EmbeddedContact.std.js';
|
import * as EmbeddedContact from '../types/EmbeddedContact.std.js';
|
||||||
|
|
||||||
export function getQuoteBodyText(
|
export function getQuoteBodyText({
|
||||||
messageAttributes: ReadonlyMessageAttributesType,
|
messageAttributes,
|
||||||
id: number | null
|
id,
|
||||||
): string | undefined {
|
i18n,
|
||||||
|
}: {
|
||||||
|
messageAttributes: ReadonlyMessageAttributesType;
|
||||||
|
id: number | null;
|
||||||
|
i18n: LocalizerType;
|
||||||
|
}): string | undefined {
|
||||||
const storyReactionEmoji = messageAttributes.storyReaction?.emoji;
|
const storyReactionEmoji = messageAttributes.storyReaction?.emoji;
|
||||||
|
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
@@ -20,11 +26,17 @@ export function getQuoteBodyText(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { body, contact: embeddedContact } = messageAttributes;
|
const { body, contact: embeddedContact, poll } = messageAttributes;
|
||||||
const embeddedContactName =
|
const embeddedContactName =
|
||||||
embeddedContact && embeddedContact.length > 0
|
embeddedContact && embeddedContact.length > 0
|
||||||
? EmbeddedContact.getName(embeddedContact[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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { getLocalAttachmentUrl } from './getLocalAttachmentUrl.std.js';
|
|||||||
import type { QuotedMessageForComposerType } from '../state/ducks/composer.preload.js';
|
import type { QuotedMessageForComposerType } from '../state/ducks/composer.preload.js';
|
||||||
|
|
||||||
const log = createLogger('makeQuote');
|
const log = createLogger('makeQuote');
|
||||||
|
const { i18n } = window.SignalContext;
|
||||||
|
|
||||||
export async function makeQuote(
|
export async function makeQuote(
|
||||||
quotedMessage: MessageAttributesType
|
quotedMessage: MessageAttributesType
|
||||||
@@ -56,7 +57,11 @@ export async function makeQuote(
|
|||||||
isGiftBadge: isGiftBadge(quotedMessage),
|
isGiftBadge: isGiftBadge(quotedMessage),
|
||||||
messageId,
|
messageId,
|
||||||
referencedMessageNotFound: false,
|
referencedMessageNotFound: false,
|
||||||
text: getQuoteBodyText(quotedMessage, quoteId),
|
text: getQuoteBodyText({
|
||||||
|
messageAttributes: quotedMessage,
|
||||||
|
id: quoteId,
|
||||||
|
i18n,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user