fix: show authorName in reply ui

pull/2757/head
William Grant 2 years ago
parent 1da8fd9f96
commit d706ecdead

@ -12,6 +12,7 @@ import { Image } from '../../../ts/components/conversation/Image';
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'; import { GoogleChrome } from '../../util';
import { findAndFormatContact } from '../../models/message';
const QuotedMessageComposition = styled(Flex)` const QuotedMessageComposition = styled(Flex)`
border-top: 1px solid var(--border-color); border-top: 1px solid var(--border-color);
@ -47,12 +48,24 @@ const StyledText = styled(Flex)`
`; `;
export const SessionQuotedMessageComposition = () => { export const SessionQuotedMessageComposition = () => {
const quotedMessageProps = useSelector(getQuotedMessage);
const dispatch = useDispatch(); const dispatch = useDispatch();
const quotedMessageProps = useSelector(getQuotedMessage);
const { author, attachments, text: quoteText } = quotedMessageProps || {}; const { author, attachments, text: quoteText } = quotedMessageProps || {};
const removeQuotedMessage = () => {
dispatch(quoteMessage(undefined));
};
useKey('Escape', removeQuotedMessage, undefined, []);
if (!author || !quotedMessageProps?.id) {
return null;
}
const contact = findAndFormatContact(author);
const authorName = contact?.profileName || contact?.name || author || window.i18n('unknown');
const hasAttachments = attachments && attachments.length > 0 && attachments[0]; const hasAttachments = attachments && attachments.length > 0 && attachments[0];
const firstImageAttachment = const firstImageAttachment =
hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail hasAttachments && attachments[0].contentType !== AUDIO_MP3 && attachments[0].thumbnail
@ -80,16 +93,6 @@ export const SessionQuotedMessageComposition = () => {
? window.i18n('image') ? window.i18n('image')
: null; : null;
const removeQuotedMessage = () => {
dispatch(quoteMessage(undefined));
};
useKey('Escape', removeQuotedMessage, undefined, []);
if (!author || !quotedMessageProps?.id) {
return null;
}
return ( return (
<QuotedMessageComposition <QuotedMessageComposition
container={true} container={true}
@ -129,7 +132,7 @@ export const SessionQuotedMessageComposition = () => {
justifyContent={'center'} justifyContent={'center'}
alignItems={'flex-start'} alignItems={'flex-start'}
> >
<p>{author}</p> <p>{authorName}</p>
{subtitleText && <Subtle>{subtitleText}</Subtle>} {subtitleText && <Subtle>{subtitleText}</Subtle>}
</StyledText> </StyledText>
</QuotedMessageCompositionReply> </QuotedMessageCompositionReply>

@ -46,7 +46,9 @@ export const CallNotification = (props: PropsForCallNotification) => {
(selectedConvoProps?.id && PubKey.shorten(selectedConvoProps?.id)); (selectedConvoProps?.id && PubKey.shorten(selectedConvoProps?.id));
const styleItem = style[notificationType]; const styleItem = style[notificationType];
const notificationText = window.i18n(styleItem.notificationTextKey, [displayName || 'Unknown']); const notificationText = window.i18n(styleItem.notificationTextKey, [
displayName || window.i18n('unknown'),
]);
if (!window.i18n(styleItem.notificationTextKey)) { if (!window.i18n(styleItem.notificationTextKey)) {
throw new Error(`invalid i18n key ${styleItem.notificationTextKey}`); throw new Error(`invalid i18n key ${styleItem.notificationTextKey}`);
} }

@ -164,7 +164,7 @@ async function onSubmit(convoId: string, membersAfterUpdate: Array<string>) {
void initiateClosedGroupUpdate( void initiateClosedGroupUpdate(
convoId, convoId,
convoProps.displayNameInProfile || 'Unknown', convoProps.displayNameInProfile || window.i18n('unknown'),
filteredMembers filteredMembers
); );
} }

@ -82,7 +82,7 @@ export class UpdateGroupNameDialog extends React.Component<Props, State> {
const okText = window.i18n('ok'); const okText = window.i18n('ok');
const cancelText = window.i18n('cancel'); const cancelText = window.i18n('cancel');
const titleText = window.i18n('updateGroupDialogTitle', [ const titleText = window.i18n('updateGroupDialogTitle', [
this.convo.getRealSessionUsername() || 'Unknown', this.convo.getRealSessionUsername() || window.i18n('unknown'),
]); ]);
const errorMsg = this.state.errorMessage; const errorMsg = this.state.errorMessage;

@ -112,8 +112,12 @@ const acceptOpenGroupInvitationV2 = (completeUrl: string, roomName?: string) =>
window.inboxStore?.dispatch( window.inboxStore?.dispatch(
updateConfirmModal({ updateConfirmModal({
title: window.i18n('joinOpenGroupAfterInvitationConfirmationTitle', [roomName || 'Unknown']), title: window.i18n('joinOpenGroupAfterInvitationConfirmationTitle', [
message: window.i18n('joinOpenGroupAfterInvitationConfirmationDesc', [roomName || 'Unknown']), roomName || window.i18n('unknown'),
]),
message: window.i18n('joinOpenGroupAfterInvitationConfirmationDesc', [
roomName || window.i18n('unknown'),
]),
onClickOk: async () => { onClickOk: async () => {
await joinOpenGroupV2WithUIEvents(completeUrl, true, false); await joinOpenGroupV2WithUIEvents(completeUrl, true, false);
}, },

@ -607,7 +607,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
} = { } = {
sender: author, sender: author,
messageId: id, messageId: id,
authorName: authorName || 'Unknown', authorName: authorName || window.i18n('unknown'),
}; };
if (referencedMessageNotFound) { if (referencedMessageNotFound) {
@ -1424,7 +1424,7 @@ export function overrideWithSourceMessage(
const sender = msgProps.sender && isEmpty(msgProps.sender) ? msgProps.sender : quote.sender; const sender = msgProps.sender && isEmpty(msgProps.sender) ? msgProps.sender : quote.sender;
const contact = findAndFormatContact(sender); const contact = findAndFormatContact(sender);
const authorName = contact?.profileName || contact?.name || 'Unknown'; const authorName = contact?.profileName || contact?.name || window.i18n('unknown');
const attachment = const attachment =
msgProps.attachments && msgProps.attachments[0] ? msgProps.attachments[0] : quote.attachment; msgProps.attachments && msgProps.attachments[0] ? msgProps.attachments[0] : quote.attachment;

@ -69,7 +69,7 @@ export async function initiateOpenGroupUpdate(
}); });
const avatarImageId = fileId; const avatarImageId = fileId;
await convo.setSessionProfile({ await convo.setSessionProfile({
displayName: groupName || convo.get('displayNameInProfile') || 'Unknown', displayName: groupName || convo.get('displayNameInProfile') || window.i18n('unknown'),
avatarPath: upgraded.path, avatarPath: upgraded.path,
avatarImageId, avatarImageId,

@ -1138,7 +1138,7 @@ export async function handleMissedCall(
const displayname = const displayname =
incomingCallConversation?.getNickname() || incomingCallConversation?.getNickname() ||
incomingCallConversation?.getRealSessionUsername() || incomingCallConversation?.getRealSessionUsername() ||
'Unknown'; window.i18n('unknown');
switch (reason) { switch (reason) {
case 'permissions': case 'permissions':

@ -883,7 +883,7 @@ export const getMessagePropsByMessageId = createSelector(
sender, sender,
authorAvatarPath: foundSenderConversation.avatarPath || null, authorAvatarPath: foundSenderConversation.avatarPath || null,
isKickedFromGroup: foundMessageConversation.isKickedFromGroup || false, isKickedFromGroup: foundMessageConversation.isKickedFromGroup || false,
authorProfileName: authorProfileName || 'Unknown', authorProfileName: authorProfileName || window.i18n('unknown'),
authorName, authorName,
}, },
}; };

Loading…
Cancel
Save