fix: Show correct attachment type in reply ui

pull/2757/head
William Grant 2 years ago
parent 761a536b32
commit 6b2047b5c6

@ -11,6 +11,7 @@ import { Image } from '../../../ts/components/conversation/Image';
// tslint:disable-next-line: no-submodule-imports // tslint:disable-next-line: no-submodule-imports
import useKey from 'react-use/lib/useKey'; import useKey from 'react-use/lib/useKey';
import { getAbsoluteAttachmentPath } from '../../types/MessageAttachment'; import { getAbsoluteAttachmentPath } from '../../types/MessageAttachment';
import { GoogleChrome } from '../../util';
const QuotedMessageComposition = styled(Flex)` const QuotedMessageComposition = styled(Flex)`
border-top: 1px solid var(--border-color); border-top: 1px solid var(--border-color);
@ -57,15 +58,26 @@ export const SessionQuotedMessageComposition = () => {
hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail
? attachments[0] ? attachments[0]
: undefined; : undefined;
const hasAudio = hasAttachments && isAudio(attachments); const isImage = Boolean(
const hasAudioAttachment = hasAudio !== false && hasAudio !== undefined && hasAudio !== ''; firstImageAttachment && GoogleChrome.isImageTypeSupported(firstImageAttachment.contentType)
);
const isVideo = Boolean(
firstImageAttachment && GoogleChrome.isVideoTypeSupported(firstImageAttachment.contentType)
);
const hasAudioAttachment = Boolean(hasAttachments && isAudio(attachments));
const isGenericFile = !hasAudioAttachment && !isVideo && !isImage;
const subtitleText = const subtitleText =
hasAttachments && firstImageAttachment quoteText !== ''
? window.i18n('image') ? quoteText
: hasAudioAttachment : hasAudioAttachment
? window.i18n('audio') ? window.i18n('audio')
: quoteText !== '' : isGenericFile
? quoteText ? window.i18n('document')
: isVideo
? window.i18n('video')
: isImage
? window.i18n('image')
: null; : null;
const removeQuotedMessage = () => { const removeQuotedMessage = () => {

@ -458,6 +458,7 @@ export async function uploadOurAvatar(newAvatarDecrypted?: ArrayBuffer) {
} }
export async function replyToMessage(messageId: string) { export async function replyToMessage(messageId: string) {
// TODO Use Quote Lookup Object here
const quotedMessageModel = await Data.getMessageById(messageId); const quotedMessageModel = await Data.getMessageById(messageId);
if (!quotedMessageModel) { if (!quotedMessageModel) {
window.log.warn('Failed to find message to reply to'); window.log.warn('Failed to find message to reply to');

Loading…
Cancel
Save