diff --git a/ts/components/conversation/H5AudioPlayer.tsx b/ts/components/conversation/H5AudioPlayer.tsx index 08b7828e7..f9aa62505 100644 --- a/ts/components/conversation/H5AudioPlayer.tsx +++ b/ts/components/conversation/H5AudioPlayer.tsx @@ -60,8 +60,8 @@ export const AudioPlayerWithEncryptedFile = (props: { // justEndedMessageIndex cannot be -1 nor 0, so it is >= 1 const nextMessageIndex = justEndedMessageIndex - 1; // stop auto-playing when the audio messages change author. - const prevAuthorNumber = messageProps[justEndedMessageIndex].propsForMessage.authorPhoneNumber; - const nextAuthorNumber = messageProps[nextMessageIndex].propsForMessage.authorPhoneNumber; + const prevAuthorNumber = messageProps[justEndedMessageIndex].propsForMessage.sender; + const nextAuthorNumber = messageProps[nextMessageIndex].propsForMessage.sender; const differentAuthor = prevAuthorNumber !== nextAuthorNumber; if (differentAuthor) { dispatch(setNextMessageToPlayId(undefined)); diff --git a/ts/components/conversation/SessionConversation.tsx b/ts/components/conversation/SessionConversation.tsx index 5fb6d815a..eac6dbb47 100644 --- a/ts/components/conversation/SessionConversation.tsx +++ b/ts/components/conversation/SessionConversation.tsx @@ -532,7 +532,6 @@ export class SessionConversation extends React.Component { return { id: pubKey, - authorPhoneNumber: pubKey, authorProfileName: profileName, }; }); diff --git a/ts/components/conversation/SessionMessagesListContainer.tsx b/ts/components/conversation/SessionMessagesListContainer.tsx index eab0e9ec5..dc0e3a708 100644 --- a/ts/components/conversation/SessionMessagesListContainer.tsx +++ b/ts/components/conversation/SessionMessagesListContainer.tsx @@ -330,7 +330,7 @@ class SessionMessagesListContainerInner extends React.Component { } // Look for message in memory first, which would tell us if we could scroll to it const targetMessage = messagesProps.find(item => { - const messageAuthor = item.propsForMessage?.authorPhoneNumber; + const messageAuthor = item.propsForMessage?.sender; if (!messageAuthor || quoteAuthor !== messageAuthor) { return false; diff --git a/ts/components/conversation/composition/CompositionBox.tsx b/ts/components/conversation/composition/CompositionBox.tsx index 3def48e30..1b12a7480 100644 --- a/ts/components/conversation/composition/CompositionBox.tsx +++ b/ts/components/conversation/composition/CompositionBox.tsx @@ -466,7 +466,7 @@ class CompositionBoxInner extends React.Component { .map(user => { return { display: user.authorProfileName, - id: user.authorPhoneNumber, + id: user.id, }; }) || []; callback(filtered); @@ -509,7 +509,6 @@ class CompositionBoxInner extends React.Component { } return { id: pubKey, - authorPhoneNumber: pubKey, authorProfileName: profileName, }; }); @@ -524,7 +523,7 @@ class CompositionBoxInner extends React.Component { // Transform the users to what react-mentions expects const mentionsData = members.map(user => ({ display: user.authorProfileName || window.i18n('anonymous'), - id: user.authorPhoneNumber, + id: user.id, })); callback(mentionsData); } diff --git a/ts/components/conversation/message/message-content/MessageAttachment.tsx b/ts/components/conversation/message/message-content/MessageAttachment.tsx index 1b1bce4f5..e37650e7c 100644 --- a/ts/components/conversation/message/message-content/MessageAttachment.tsx +++ b/ts/components/conversation/message/message-content/MessageAttachment.tsx @@ -38,7 +38,7 @@ export type MessageAttachmentSelectorProps = Pick< | 'direction' | 'timestamp' | 'serverTimestamp' - | 'authorPhoneNumber' + | 'sender' | 'convoId' > & { attachments: Array; @@ -81,11 +81,11 @@ export const MessageAttachment = (props: Props) => { } const messageTimestamp = attachmentProps?.timestamp || attachmentProps?.serverTimestamp || 0; - if (attachmentProps?.authorPhoneNumber && attachmentProps?.convoId) { + if (attachmentProps?.sender && attachmentProps?.convoId) { void saveAttachmentToDisk({ attachment: attachments[0], messageTimestamp, - messageSender: attachmentProps?.authorPhoneNumber, + messageSender: attachmentProps?.sender, conversationId: attachmentProps?.convoId, }); } @@ -94,7 +94,7 @@ export const MessageAttachment = (props: Props) => { attachmentProps?.attachments, attachmentProps?.timestamp, attachmentProps?.serverTimestamp, - attachmentProps?.authorPhoneNumber, + attachmentProps?.sender, attachmentProps?.convoId, ] ); diff --git a/ts/components/conversation/message/message-content/MessageAuthorText.tsx b/ts/components/conversation/message/message-content/MessageAuthorText.tsx index b84f365d5..acb2e945c 100644 --- a/ts/components/conversation/message/message-content/MessageAuthorText.tsx +++ b/ts/components/conversation/message/message-content/MessageAuthorText.tsx @@ -12,7 +12,7 @@ import { ContactName } from '../../ContactName'; export type MessageAuthorSelectorProps = Pick< MessageRenderingProps, - 'authorName' | 'authorProfileName' | 'authorPhoneNumber' | 'direction' | 'firstMessageOfSeries' + 'authorName' | 'authorProfileName' | 'sender' | 'direction' | 'firstMessageOfSeries' >; type Props = { @@ -27,23 +27,17 @@ export const MessageAuthorText = (props: Props) => { if (!selected) { return null; } - const { - authorName, - authorPhoneNumber, - authorProfileName, - direction, - firstMessageOfSeries, - } = selected; + const { authorName, sender, authorProfileName, direction, firstMessageOfSeries } = selected; - const title = authorName ? authorName : authorPhoneNumber; + const title = authorName ? authorName : sender; if (direction !== 'incoming' || !isGroup || !title || !firstMessageOfSeries) { return null; } - const shortenedPubkey = PubKey.shorten(authorPhoneNumber); + const shortenedPubkey = PubKey.shorten(sender); - const displayedPubkey = authorProfileName ? shortenedPubkey : authorPhoneNumber; + const displayedPubkey = authorProfileName ? shortenedPubkey : sender; return ( diff --git a/ts/components/conversation/message/message-content/MessageAvatar.tsx b/ts/components/conversation/message/message-content/MessageAvatar.tsx index 473da4c29..0728bd65e 100644 --- a/ts/components/conversation/message/message-content/MessageAvatar.tsx +++ b/ts/components/conversation/message/message-content/MessageAvatar.tsx @@ -10,7 +10,7 @@ export type MessageAvatarSelectorProps = Pick< MessageRenderingProps, | 'authorAvatarPath' | 'authorName' - | 'authorPhoneNumber' + | 'sender' | 'authorProfileName' | 'isSenderAdmin' | 'conversationType' @@ -33,7 +33,7 @@ export const MessageAvatar = (props: Props) => { const { authorAvatarPath, authorName, - authorPhoneNumber, + sender, authorProfileName, conversationType, direction, @@ -45,28 +45,28 @@ export const MessageAvatar = (props: Props) => { if (conversationType !== 'group' || direction === 'outgoing') { return null; } - const userName = authorName || authorProfileName || authorPhoneNumber; + const userName = authorName || authorProfileName || sender; const onMessageAvatarClick = useCallback(() => { dispatch( updateUserDetailsModal({ - conversationId: authorPhoneNumber, + conversationId: sender, userName, authorAvatarPath, }) ); - }, [userName, authorPhoneNumber, authorAvatarPath]); + }, [userName, sender, authorAvatarPath]); if (!lastMessageOfSeries) { - return
; + return
; } return ( -
+
{isSenderAdmin && }
diff --git a/ts/components/conversation/message/message-content/MessageContextMenu.tsx b/ts/components/conversation/message/message-content/MessageContextMenu.tsx index dcc01652e..c23239f9b 100644 --- a/ts/components/conversation/message/message-content/MessageContextMenu.tsx +++ b/ts/components/conversation/message/message-content/MessageContextMenu.tsx @@ -26,7 +26,7 @@ import { saveAttachmentToDisk } from '../../../../util/attachmentsUtil'; export type MessageContextMenuSelectorProps = Pick< MessageRenderingProps, | 'attachments' - | 'authorPhoneNumber' + | 'sender' | 'convoId' | 'direction' | 'status' @@ -54,7 +54,7 @@ export const MessageContextMenu = (props: Props) => { } const { attachments, - authorPhoneNumber, + sender, convoId, direction, status, @@ -103,12 +103,12 @@ export const MessageContextMenu = (props: Props) => { const unsendMessageText = window.i18n('deleteForEveryone'); const addModerator = useCallback(() => { - void addSenderAsModerator(authorPhoneNumber, convoId); - }, [authorPhoneNumber, convoId]); + void addSenderAsModerator(sender, convoId); + }, [sender, convoId]); const removeModerator = useCallback(() => { - void removeSenderFromModerator(authorPhoneNumber, convoId); - }, [authorPhoneNumber, convoId]); + void removeSenderFromModerator(sender, convoId); + }, [sender, convoId]); const onReply = useCallback(() => { if (isBlocked) { @@ -128,11 +128,11 @@ export const MessageContextMenu = (props: Props) => { void saveAttachmentToDisk({ attachment: attachments[0], messageTimestamp, - messageSender: authorPhoneNumber, + messageSender: sender, conversationId: convoId, }); }, - [convoId, authorPhoneNumber, timestamp, serverTimestamp, convoId, attachments] + [convoId, sender, timestamp, serverTimestamp, convoId, attachments] ); const copyText = useCallback(() => { @@ -147,12 +147,12 @@ export const MessageContextMenu = (props: Props) => { }, [messageId]); const onBan = useCallback(() => { - MessageInteraction.banUser(authorPhoneNumber, convoId); - }, [authorPhoneNumber, convoId]); + MessageInteraction.banUser(sender, convoId); + }, [sender, convoId]); const onUnban = useCallback(() => { - MessageInteraction.unbanUser(authorPhoneNumber, convoId); - }, [authorPhoneNumber, convoId]); + MessageInteraction.unbanUser(sender, convoId); + }, [sender, convoId]); const onSelect = useCallback(() => { dispatch(toggleSelectedMessageId(messageId)); diff --git a/ts/components/conversation/message/message-content/MessageQuote.tsx b/ts/components/conversation/message/message-content/MessageQuote.tsx index f386da13d..ceae41911 100644 --- a/ts/components/conversation/message/message-content/MessageQuote.tsx +++ b/ts/components/conversation/message/message-content/MessageQuote.tsx @@ -40,11 +40,11 @@ export const MessageQuote = (props: Props) => { return; } - const { authorPhoneNumber, referencedMessageNotFound, messageId } = selected.quote; + const { sender, referencedMessageNotFound, messageId } = selected.quote; const quoteId = _.toNumber(messageId); scrollToQuote?.({ - quoteAuthor: authorPhoneNumber, + quoteAuthor: sender, quoteId, referencedMessageNotFound: referencedMessageNotFound || false, }); @@ -57,12 +57,12 @@ export const MessageQuote = (props: Props) => { const { quote, direction } = selected; - if (!quote || !quote.authorPhoneNumber || !quote.messageId) { + if (!quote || !quote.sender || !quote.messageId) { return null; } - const shortenedPubkey = PubKey.shorten(quote.authorPhoneNumber); + const shortenedPubkey = PubKey.shorten(quote.sender); - const displayedPubkey = quote.authorProfileName ? shortenedPubkey : quote.authorPhoneNumber; + const displayedPubkey = quote.authorProfileName ? shortenedPubkey : quote.sender; return ( { text={quote.text || ''} attachment={quote.attachment} isIncoming={direction === 'incoming'} - authorPhoneNumber={displayedPubkey} + sender={displayedPubkey} authorProfileName={quote.authorProfileName} authorName={quote.authorName} referencedMessageNotFound={quote.referencedMessageNotFound || false} diff --git a/ts/components/conversation/message/message-content/Quote.tsx b/ts/components/conversation/message/message-content/Quote.tsx index 9dc700de0..761bb1e2f 100644 --- a/ts/components/conversation/message/message-content/Quote.tsx +++ b/ts/components/conversation/message/message-content/Quote.tsx @@ -20,7 +20,7 @@ import { MessageBody } from './MessageBody'; export type QuotePropsWithoutListener = { attachment?: QuotedAttachmentType; - authorPhoneNumber: string; + sender: string; authorProfileName?: string; authorName?: string; isFromMe: boolean; @@ -269,7 +269,7 @@ export const QuoteText = ( }; type QuoteAuthorProps = { - authorPhoneNumber: string; + author: string; authorProfileName?: string; authorName?: string; isFromMe: boolean; @@ -278,7 +278,7 @@ type QuoteAuthorProps = { }; const QuoteAuthor = (props: QuoteAuthorProps) => { - const { authorProfileName, authorPhoneNumber, authorName, isFromMe, isIncoming } = props; + const { authorProfileName, author, authorName, isFromMe, isIncoming } = props; return (
{ window.i18n('you') ) : ( {
{ id: this.id, direction: (this.isIncoming() ? 'incoming' : 'outgoing') as MessageModelType, timestamp: this.get('sent_at') || 0, - authorPhoneNumber: sender, + sender, convoId: this.get('conversationId'), }; if (body) { @@ -557,14 +557,14 @@ export class MessageModel extends Backbone.Model { const firstAttachment = quote.attachments && quote.attachments[0]; const quoteProps: { referencedMessageNotFound?: boolean; - authorPhoneNumber: string; + sender: string; messageId: string; authorName: string; text?: string; attachment?: any; isFromMe?: boolean; } = { - authorPhoneNumber: author, + sender: author, messageId: id, authorName: authorName || 'Unknown', }; diff --git a/ts/state/ducks/conversations.ts b/ts/state/ducks/conversations.ts index d19a83231..f24bffe87 100644 --- a/ts/state/ducks/conversations.ts +++ b/ts/state/ducks/conversations.ts @@ -165,7 +165,7 @@ export type PropsForMessageWithoutConvoProps = { id: string; // messageId direction: MessageModelType; timestamp: number; - authorPhoneNumber: string; // this is the sender + sender: string; // this is the sender convoId: string; // this is the conversation in which this message was sent text?: string; @@ -179,7 +179,7 @@ export type PropsForMessageWithoutConvoProps = { text?: string; attachment?: QuotedAttachmentType; isFromMe?: boolean; - authorPhoneNumber: string; + sender: string; authorProfileName?: string; authorName?: string; messageId?: string; @@ -283,7 +283,6 @@ export type ConversationsStateType = { export type MentionsMembersType = Array<{ id: string; - authorPhoneNumber: string; authorProfileName: string; }>; diff --git a/ts/state/selectors/conversations.ts b/ts/state/selectors/conversations.ts index 781d9cfa1..a7e94b936 100644 --- a/ts/state/selectors/conversations.ts +++ b/ts/state/selectors/conversations.ts @@ -667,14 +667,13 @@ function updateFirstMessageOfSeries( const sortedMessageProps: Array = []; for (let i = 0; i < messageModelsProps.length; i++) { - const currentSender = messageModelsProps[i].propsForMessage?.authorPhoneNumber; + const currentSender = messageModelsProps[i].propsForMessage?.sender; // most recent message is at index 0, so the previous message sender is 1+index const previousSender = i < messageModelsProps.length - 1 - ? messageModelsProps[i + 1].propsForMessage?.authorPhoneNumber + ? messageModelsProps[i + 1].propsForMessage?.sender : undefined; - const nextSender = - i > 0 ? messageModelsProps[i - 1].propsForMessage?.authorPhoneNumber : undefined; + const nextSender = i > 0 ? messageModelsProps[i - 1].propsForMessage?.sender : undefined; // Handle firstMessageOfSeries for conditional avatar rendering sortedMessageProps.push({ @@ -773,14 +772,14 @@ export const getMessagePropsByMessageId = createSelector( if (!foundMessageProps || !foundMessageProps.propsForMessage.convoId) { return undefined; } - const authorPhoneNumber = foundMessageProps?.propsForMessage?.authorPhoneNumber; + const sender = foundMessageProps?.propsForMessage?.sender; const foundMessageConversation = conversations[foundMessageProps.propsForMessage.convoId]; - if (!foundMessageConversation || !authorPhoneNumber) { + if (!foundMessageConversation || !sender) { return undefined; } - const foundSenderConversation = conversations[authorPhoneNumber]; + const foundSenderConversation = conversations[sender]; if (!foundSenderConversation) { return undefined; } @@ -795,16 +794,15 @@ export const getMessagePropsByMessageId = createSelector( // either we sent it, // or the convo is not a public one (in this case, we will only be able to delete for us) // or the convo is public and we are an admin - const isDeletable = authorPhoneNumber === ourPubkey || !isPublic || (isPublic && !!weAreAdmin); + const isDeletable = sender === ourPubkey || !isPublic || (isPublic && !!weAreAdmin); // A message is deletable for everyone if // either we sent it no matter what the conversation type, // or the convo is public and we are an admin - const isDeletableForEveryone = - authorPhoneNumber === ourPubkey || (isPublic && !!weAreAdmin) || false; + const isDeletableForEveryone = sender === ourPubkey || (isPublic && !!weAreAdmin) || false; - const isSenderAdmin = groupAdmins.includes(authorPhoneNumber); - const senderIsUs = authorPhoneNumber === ourPubkey; + const isSenderAdmin = groupAdmins.includes(sender); + const senderIsUs = sender === ourPubkey; const authorName = foundSenderConversation.name || null; const authorProfileName = senderIsUs ? window.i18n('you') : foundSenderConversation.profileName; @@ -821,7 +819,7 @@ export const getMessagePropsByMessageId = createSelector( isDeletableForEveryone, weAreAdmin, conversationType: foundMessageConversation.type, - authorPhoneNumber, + sender, authorAvatarPath: foundSenderConversation.avatarPath || null, isKickedFromGroup: foundMessageConversation.isKickedFromGroup || false, authorProfileName: authorProfileName || 'Unknown', @@ -843,7 +841,7 @@ export const getMessageAvatarProps = createSelector(getMessagePropsByMessageId, const { authorAvatarPath, authorName, - authorPhoneNumber, + sender, authorProfileName, conversationType, direction, @@ -856,7 +854,7 @@ export const getMessageAvatarProps = createSelector(getMessagePropsByMessageId, const messageAvatarProps: MessageAvatarSelectorProps = { authorAvatarPath, authorName, - authorPhoneNumber, + sender, authorProfileName, conversationType, direction, @@ -949,7 +947,7 @@ export const getMessageContextMenuProps = createSelector(getMessagePropsByMessag const { attachments, - authorPhoneNumber, + sender, convoId, direction, status, @@ -967,7 +965,7 @@ export const getMessageContextMenuProps = createSelector(getMessagePropsByMessag const msgProps: MessageContextMenuSelectorProps = { attachments, - authorPhoneNumber, + sender, convoId, direction, status, @@ -993,12 +991,12 @@ export const getMessageAuthorProps = createSelector(getMessagePropsByMessageId, return undefined; } - const { authorName, authorPhoneNumber, authorProfileName, direction } = props.propsForMessage; + const { authorName, sender, authorProfileName, direction } = props.propsForMessage; const { firstMessageOfSeries } = props; const msgProps: MessageAuthorSelectorProps = { authorName, - authorPhoneNumber, + sender, authorProfileName, direction, firstMessageOfSeries, @@ -1031,7 +1029,7 @@ export const getMessageAttachmentProps = createSelector(getMessagePropsByMessage isTrustedForAttachmentDownload, timestamp, serverTimestamp, - authorPhoneNumber, + sender, convoId, } = props.propsForMessage; const msgProps: MessageAttachmentSelectorProps = { @@ -1040,7 +1038,7 @@ export const getMessageAttachmentProps = createSelector(getMessagePropsByMessage isTrustedForAttachmentDownload, timestamp, serverTimestamp, - authorPhoneNumber, + sender, convoId, };