From 0d5c72555bd4c0de286ed62a6dc50b643388ad79 Mon Sep 17 00:00:00 2001 From: William Grant Date: Mon, 24 Apr 2023 14:44:46 +1000 Subject: [PATCH] feat: started updating reply to ui finished text reply --- ts/components/conversation/Emojify.tsx | 3 +- .../SessionQuotedMessageComposition.tsx | 107 ++++++++++-------- ts/models/conversation.ts | 4 + ts/state/ducks/conversations.ts | 1 + 4 files changed, 65 insertions(+), 50 deletions(-) diff --git a/ts/components/conversation/Emojify.tsx b/ts/components/conversation/Emojify.tsx index e86717a4a..f54ccfcbb 100644 --- a/ts/components/conversation/Emojify.tsx +++ b/ts/components/conversation/Emojify.tsx @@ -36,9 +36,8 @@ export const Emojify = (props: Props): JSX.Element => { size = 1.1; break; case 'default': - size = 1.0; - break; default: + size = 1.0; } return {rendered}; diff --git a/ts/components/conversation/SessionQuotedMessageComposition.tsx b/ts/components/conversation/SessionQuotedMessageComposition.tsx index 88313d065..7cd5ce9d6 100644 --- a/ts/components/conversation/SessionQuotedMessageComposition.tsx +++ b/ts/components/conversation/SessionQuotedMessageComposition.tsx @@ -10,34 +10,39 @@ import { Flex } from '../basic/Flex'; import { Image } from '../../../ts/components/conversation/Image'; // tslint:disable-next-line: no-submodule-imports import useKey from 'react-use/lib/useKey'; +import { getAbsoluteAttachmentPath } from '../../types/MessageAttachment'; -const QuotedMessageComposition = styled.div` - background-color: var(--background-secondary-color); - width: 100%; - padding-inline-end: var(--margins-md); - padding-inline-start: var(--margins-md); - padding-bottom: var(--margins-xs); +const QuotedMessageComposition = styled(Flex)` + border-top: 1px solid var(--border-color); `; -const QuotedMessageCompositionReply = styled.div` - background: var(--message-bubbles-received-background-color); - border-radius: var(--margins-sm); - padding: var(--margins-xs); - margin: var(--margins-xs); +const QuotedMessageCompositionReply = styled(Flex)` + border-left: 3px solid var(--primary-color); `; const Subtle = styled.div` overflow: hidden; text-overflow: ellipsis; word-break: break-all; - -webkit-line-clamp: 2; + -webkit-line-clamp: 1; -webkit-box-orient: vertical; display: -webkit-box; color: var(--text-primary-color); `; -const ReplyingTo = styled.div` - color: var(--text-primary-color); +const StyledImage = styled.div` + div { + border-radius: 4px; + overflow: hidden; + } +`; + +const StyledText = styled(Flex)` + margin: 0 0 0 var(--margins-sm); + p { + font-weight: bold; + margin: 0; + } `; export const SessionQuotedMessageComposition = () => { @@ -45,21 +50,15 @@ export const SessionQuotedMessageComposition = () => { const dispatch = useDispatch(); - const { text: body, attachments } = quotedMessageProps || {}; - const hasAttachments = attachments && attachments.length > 0; - - let hasImageAttachment = false; + const { author, attachments, text: quoteText } = quotedMessageProps || {}; - let firstImageAttachment; - // we have to handle the case we are trying to reply to an audio message - - if (attachments?.length && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail) { - firstImageAttachment = attachments[0]; - hasImageAttachment = true; - } - - const hasAudioAttachment = - hasAttachments && attachments && attachments.length > 0 && isAudio(attachments); + const hasAttachments = attachments && attachments.length > 0 && attachments[0]; + const firstImageAttachment = + hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail + ? attachments[0] + : undefined; + const hasAudio = hasAttachments && isAudio(attachments); + const hasAudioAttachment = hasAudio !== false && hasAudio !== undefined && hasAudio !== ''; const removeQuotedMessage = () => { dispatch(quoteMessage(undefined)); @@ -67,40 +66,52 @@ export const SessionQuotedMessageComposition = () => { useKey('Escape', removeQuotedMessage, undefined, []); - if (!quotedMessageProps?.id) { + if (!author || !quotedMessageProps?.id) { return null; } return ( - - + - {window.i18n('replyingToMessage')} - - - - - {(hasAttachments && window.i18n('mediaMessage')) || body} - - {hasImageAttachment && ( + {firstImageAttachment && ( + {getAlt(firstImageAttachment)} - )} - - {hasAudioAttachment && } - + + )} + +

{author}

+ + {(firstImageAttachment && window.i18n('mediaMessage')) || + (quoteText !== '' && quoteText)} + +
+ + {hasAudioAttachment && }
+
); }; diff --git a/ts/models/conversation.ts b/ts/models/conversation.ts index 1969eaf19..aeda1410f 100644 --- a/ts/models/conversation.ts +++ b/ts/models/conversation.ts @@ -517,6 +517,10 @@ export class ConversationModel extends Backbone.Model { msgSource = await findCachedOurBlindedPubkeyOrLookItUp(room.serverPublicKey, sodium); } } + + const { title, isMe } = quotedMessage.findAndFormatContact(msgSource); + msgSource = isMe ? window.i18n('you') : title ? title : msgSource; + return { author: msgSource, id: `${quotedMessage.get('sent_at')}` || '', diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index e9ed9b6d2..ddf43edd3 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -287,6 +287,7 @@ export type ConversationLookupType = { export type ConversationsStateType = { conversationLookup: ConversationLookupType; selectedConversation?: string; + // NOTE the messages that are in view messages: Array; firstUnreadMessageId: string | undefined; messageDetailProps?: MessagePropsDetails;