mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-07-25 23:48:13 +01:00
8efd06f9d8
Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
61 lines
1.4 KiB
TypeScript
61 lines
1.4 KiB
TypeScript
// Copyright 2026 Signal Messenger, LLC
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
import type { ConversationAttributesType } from '../model-types.d.ts';
|
|
|
|
export function getExternalAvatarFilesForConversation(
|
|
conversation: Pick<ConversationAttributesType, 'avatar' | 'profileAvatar'>
|
|
): Array<string> {
|
|
const { avatar, profileAvatar } = conversation;
|
|
const files: Array<string> = [];
|
|
|
|
if (avatar && avatar.path) {
|
|
files.push(avatar.path);
|
|
}
|
|
|
|
if (profileAvatar && profileAvatar.path) {
|
|
files.push(profileAvatar.path);
|
|
}
|
|
|
|
return files;
|
|
}
|
|
|
|
export function getExternalAvatarDraftsForConversation(
|
|
conversation: Pick<ConversationAttributesType, 'avatars'>
|
|
): Array<string> {
|
|
const { avatars } = conversation;
|
|
const files: Array<string> = [];
|
|
|
|
(avatars || []).forEach(item => {
|
|
if (item.imagePath) {
|
|
files.push(item.imagePath);
|
|
}
|
|
});
|
|
|
|
return files;
|
|
}
|
|
|
|
export function getExternalDraftFilesForConversation(
|
|
conversation: Pick<ConversationAttributesType, 'draftAttachments'>
|
|
): Array<string> {
|
|
const draftAttachments = conversation.draftAttachments || [];
|
|
const files: Array<string> = [];
|
|
|
|
(draftAttachments || []).forEach(attachment => {
|
|
if (attachment.pending) {
|
|
return;
|
|
}
|
|
|
|
const { path: file, screenshotPath } = attachment;
|
|
if (file) {
|
|
files.push(file);
|
|
}
|
|
|
|
if (screenshotPath) {
|
|
files.push(screenshotPath);
|
|
}
|
|
});
|
|
|
|
return files;
|
|
}
|