feat: started updating reply to ui

finished text reply
pull/2757/head
William Grant 3 years ago
parent c6976a6cc2
commit 0d5c72555b

@ -36,9 +36,8 @@ export const Emojify = (props: Props): JSX.Element => {
size = 1.1; size = 1.1;
break; break;
case 'default': case 'default':
size = 1.0;
break;
default: default:
size = 1.0;
} }
return <span style={{ fontSize: `${size}rem`, userSelect: 'inherit' }}>{rendered}</span>; return <span style={{ fontSize: `${size}rem`, userSelect: 'inherit' }}>{rendered}</span>;

@ -10,34 +10,39 @@ import { Flex } from '../basic/Flex';
import { Image } from '../../../ts/components/conversation/Image'; 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';
const QuotedMessageComposition = styled.div` const QuotedMessageComposition = styled(Flex)`
background-color: var(--background-secondary-color); border-top: 1px solid var(--border-color);
width: 100%;
padding-inline-end: var(--margins-md);
padding-inline-start: var(--margins-md);
padding-bottom: var(--margins-xs);
`; `;
const QuotedMessageCompositionReply = styled.div` const QuotedMessageCompositionReply = styled(Flex)`
background: var(--message-bubbles-received-background-color); border-left: 3px solid var(--primary-color);
border-radius: var(--margins-sm);
padding: var(--margins-xs);
margin: var(--margins-xs);
`; `;
const Subtle = styled.div` const Subtle = styled.div`
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
word-break: break-all; word-break: break-all;
-webkit-line-clamp: 2; -webkit-line-clamp: 1;
-webkit-box-orient: vertical; -webkit-box-orient: vertical;
display: -webkit-box; display: -webkit-box;
color: var(--text-primary-color); color: var(--text-primary-color);
`; `;
const ReplyingTo = styled.div` const StyledImage = styled.div`
color: var(--text-primary-color); 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 = () => { export const SessionQuotedMessageComposition = () => {
@ -45,21 +50,15 @@ export const SessionQuotedMessageComposition = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const { text: body, attachments } = quotedMessageProps || {}; const { author, attachments, text: quoteText } = quotedMessageProps || {};
const hasAttachments = attachments && attachments.length > 0;
let hasImageAttachment = false;
let firstImageAttachment; const hasAttachments = attachments && attachments.length > 0 && attachments[0];
// we have to handle the case we are trying to reply to an audio message const firstImageAttachment =
hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail
if (attachments?.length && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail) { ? attachments[0]
firstImageAttachment = attachments[0]; : undefined;
hasImageAttachment = true; const hasAudio = hasAttachments && isAudio(attachments);
} const hasAudioAttachment = hasAudio !== false && hasAudio !== undefined && hasAudio !== '';
const hasAudioAttachment =
hasAttachments && attachments && attachments.length > 0 && isAudio(attachments);
const removeQuotedMessage = () => { const removeQuotedMessage = () => {
dispatch(quoteMessage(undefined)); dispatch(quoteMessage(undefined));
@ -67,40 +66,52 @@ export const SessionQuotedMessageComposition = () => {
useKey('Escape', removeQuotedMessage, undefined, []); useKey('Escape', removeQuotedMessage, undefined, []);
if (!quotedMessageProps?.id) { if (!author || !quotedMessageProps?.id) {
return null; return null;
} }
return ( return (
<QuotedMessageComposition> <QuotedMessageComposition
<Flex container={true}
justifyContent="space-between"
alignItems="center"
width={'100%'}
flexGrow={1}
padding={'var(--margins-md)'}
>
<QuotedMessageCompositionReply
container={true} container={true}
justifyContent="space-between" justifyContent="flex-start"
flexGrow={1} alignItems={'center'}
margin={'0 var(--margins-xs) var(--margins-xs)'}
padding={'var(--margins-xs)'}
> >
<ReplyingTo>{window.i18n('replyingToMessage')}</ReplyingTo> {firstImageAttachment && (
<SessionIconButton iconType="exit" iconSize="small" onClick={removeQuotedMessage} /> <StyledImage>
</Flex>
<QuotedMessageCompositionReply>
<Flex container={true} justifyContent="space-between" margin={'var(--margins-xs)'}>
<Subtle>{(hasAttachments && window.i18n('mediaMessage')) || body}</Subtle>
{hasImageAttachment && (
<Image <Image
alt={getAlt(firstImageAttachment)} alt={getAlt(firstImageAttachment)}
attachment={firstImageAttachment} attachment={firstImageAttachment}
height={100} height={100}
width={100} width={100}
url={firstImageAttachment.thumbnail.objectUrl} url={getAbsoluteAttachmentPath((firstImageAttachment as any).thumbnail.path)}
softCorners={false} softCorners={false}
/> />
)} </StyledImage>
)}
{hasAudioAttachment && <SessionIcon iconType="microphone" iconSize="huge" />} <StyledText
</Flex> container={true}
flexDirection="column"
justifyContent={'center'}
alignItems={'flex-start'}
>
<p>{author}</p>
<Subtle>
{(firstImageAttachment && window.i18n('mediaMessage')) ||
(quoteText !== '' && quoteText)}
</Subtle>
</StyledText>
{hasAudioAttachment && <SessionIcon iconType="microphone" iconSize="huge" />}
</QuotedMessageCompositionReply> </QuotedMessageCompositionReply>
<SessionIconButton iconType="exit" iconSize="small" onClick={removeQuotedMessage} />
</QuotedMessageComposition> </QuotedMessageComposition>
); );
}; };

@ -517,6 +517,10 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
msgSource = await findCachedOurBlindedPubkeyOrLookItUp(room.serverPublicKey, sodium); msgSource = await findCachedOurBlindedPubkeyOrLookItUp(room.serverPublicKey, sodium);
} }
} }
const { title, isMe } = quotedMessage.findAndFormatContact(msgSource);
msgSource = isMe ? window.i18n('you') : title ? title : msgSource;
return { return {
author: msgSource, author: msgSource,
id: `${quotedMessage.get('sent_at')}` || '', id: `${quotedMessage.get('sent_at')}` || '',

@ -287,6 +287,7 @@ export type ConversationLookupType = {
export type ConversationsStateType = { export type ConversationsStateType = {
conversationLookup: ConversationLookupType; conversationLookup: ConversationLookupType;
selectedConversation?: string; selectedConversation?: string;
// NOTE the messages that are in view
messages: Array<MessageModelPropsWithoutConvoProps>; messages: Array<MessageModelPropsWithoutConvoProps>;
firstUnreadMessageId: string | undefined; firstUnreadMessageId: string | undefined;
messageDetailProps?: MessagePropsDetails; messageDetailProps?: MessagePropsDetails;

Loading…
Cancel
Save