diff --git a/stylesheets/_session.scss b/stylesheets/_session.scss index 46695f5f9..9740dfedb 100644 --- a/stylesheets/_session.scss +++ b/stylesheets/_session.scss @@ -412,6 +412,7 @@ textarea { display: inline-flex; margin-inline-end: 20px; padding-top: 5px; + margin-bottom: auto; } .module-message__container { diff --git a/stylesheets/_session_conversation.scss b/stylesheets/_session_conversation.scss index 3d0c21afc..02624abe5 100644 --- a/stylesheets/_session_conversation.scss +++ b/stylesheets/_session_conversation.scss @@ -183,6 +183,7 @@ letter-spacing: 0.03em; margin-top: 3px; margin-bottom: 3px; + display: flex; } .composition-container { diff --git a/ts/components/conversation/Message.tsx b/ts/components/conversation/Message.tsx index 6f3650d0d..41d53d804 100644 --- a/ts/components/conversation/Message.tsx +++ b/ts/components/conversation/Message.tsx @@ -96,6 +96,7 @@ export interface Props { isKickedFromGroup: boolean; // whether or not to show check boxes multiSelectMode: boolean; + firstMessageOfSeries: boolean; onClickAttachment?: (attachment: AttachmentType) => void; onClickLinkPreview?: (url: string) => void; @@ -709,6 +710,7 @@ export class Message extends React.PureComponent { conversationType, direction, onShowUserDetails, + firstMessageOfSeries, } = this.props; if ( @@ -720,6 +722,10 @@ export class Message extends React.PureComponent { } const userName = authorName || authorProfileName || authorPhoneNumber; + if (!firstMessageOfSeries) { + return
; + } + return (
{ conversationType, isPublic, text, + firstMessageOfSeries, } = this.props; const { expired, expiring } = this.state; diff --git a/ts/components/session/conversation/SessionConversation.tsx b/ts/components/session/conversation/SessionConversation.tsx index 32f54a8e9..b8e2614e8 100644 --- a/ts/components/session/conversation/SessionConversation.tsx +++ b/ts/components/session/conversation/SessionConversation.tsx @@ -332,20 +332,11 @@ export class SessionConversation extends React.Component { // in the conversation model. // The only time we need to call getMessages() is to grab more messages on scroll. const { initialFetchComplete } = this.state; - const { conversationKey } = this.props; if (initialFetchComplete) { return; } - const messageSet = await window.Signal.Data.getMessagesByConversation( - conversationKey, - { - limit: Constants.CONVERSATION.DEFAULT_MESSAGE_FETCH_COUNT, - MessageCollection: window.Whisper.MessageCollection, - } - ); - - this.setState({ messages: messageSet.models }); + return this.getMessages(Constants.CONVERSATION.DEFAULT_MESSAGE_FETCH_COUNT); } public async getMessages(numMessages?: number) { @@ -372,16 +363,27 @@ export class SessionConversation extends React.Component { const messageModels = messageSet.models; const messages = []; - let previousSender; + // no need to do that `firstMessageOfSeries` on a private chat + if (this.props.conversation.type === 'direct') { + this.setState({ messages: messageSet.models }); + return; + } + + // messages are got from the more recent to the oldest, so we need to check if + // the next messages in the list is still the same author. + // The message is the first of the series if the next message is not from the same authori for (let i = 0; i < messageModels.length; i++) { // Handle firstMessageOfSeries for conditional avatar rendering let firstMessageOfSeries = true; - if (i > 0 && previousSender === messageModels[i].authorPhoneNumber) { + const currentSender = messageModels[i].propsForMessage?.authorPhoneNumber; + const nextSender = + i < messageModels.length - 1 + ? messageModels[i + 1].propsForMessage?.authorPhoneNumber + : undefined; + if (i > 0 && currentSender === nextSender) { firstMessageOfSeries = false; } - messages.push({ ...messageModels[i], firstMessageOfSeries }); - previousSender = messageModels[i].authorPhoneNumber; } this.setState({ messages });