signal-desktop/ts/util/getStoryReplyText.ts

40 lines
991 B
TypeScript
Raw Normal View History

// Copyright 2022 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import type { AttachmentType } from '../types/Attachment';
import type { LocalizerType } from '../types/Util';
import { isGIF, isImage, isVideo } from '../types/Attachment';
export function getStoryReplyText(
i18n: LocalizerType,
attachment?: AttachmentType
): string {
if (!attachment) {
2023-03-30 00:03:25 +00:00
return i18n('icu:Quote__story-unavailable');
}
if (attachment.caption) {
return attachment.caption;
}
const attachments = [attachment];
if (isImage(attachments)) {
2023-03-30 00:03:25 +00:00
return i18n('icu:message--getNotificationText--photo');
}
if (isGIF(attachments)) {
2023-03-30 00:03:25 +00:00
return i18n('icu:message--getNotificationText--gif');
}
if (isVideo(attachments)) {
2023-03-30 00:03:25 +00:00
return i18n('icu:message--getNotificationText--video');
}
if (attachment.textAttachment && attachment.textAttachment.text) {
return attachment.textAttachment.text;
}
2023-03-30 00:03:25 +00:00
return i18n('icu:message--getNotificationText--file');
}