Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: show read receipt in message header (WPB-6284) #16851

Merged
merged 4 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('message', () => {
isLastDeliveredMessage: false,
hideHeader: false,
message,
lastMessageInGroup: new ContentMessage(),
onClickAvatar: jest.fn(),
onClickButton: jest.fn(),
onClickCancelRequest: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {ReadIndicator} from 'Components/MessagesList/Message/ReadIndicator';
import {Conversation} from 'src/script/entity/Conversation';
import {CompositeMessage} from 'src/script/entity/message/CompositeMessage';
import {ContentMessage} from 'src/script/entity/message/ContentMessage';
import {Message} from 'src/script/entity/message/Message';
import {useRelativeTimestamp} from 'src/script/hooks/useRelativeTimestamp';
import {StatusType} from 'src/script/message/StatusType';
import {useKoSubscribableChildren} from 'Util/ComponentUtil';
Expand Down Expand Up @@ -58,6 +59,7 @@ export interface ContentMessageProps extends Omit<MessageActions, 'onClickResetS
isFocused: boolean;
isLastDeliveredMessage: boolean;
message: ContentMessage;
lastMessageInGroup: Message;
onClickButton: (message: CompositeMessage, buttonId: string) => void;
onRetry: (message: ContentMessage) => void;
quotedMessage?: ContentMessage;
Expand All @@ -69,6 +71,7 @@ export interface ContentMessageProps extends Omit<MessageActions, 'onClickResetS
export const ContentMessageComponent = ({
conversation,
message,
lastMessageInGroup,
findMessage,
selfId,
hideHeader,
Expand Down Expand Up @@ -177,6 +180,12 @@ export const ContentMessageComponent = ({
{timeAgo}
</MessageTime>
</span>
<ReadIndicator
message={lastMessageInGroup}
is1to1Conversation={conversation.is1to1()}
isLastDeliveredMessage={isLastDeliveredMessage || lastMessageInGroup.status() === StatusType.DELIVERED}
showIconOnly
/>
Comment on lines +183 to +188
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of the message directly after the header, we pass the last message in the group to the read indicator.

</MessageHeader>
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export const MessageWrapper: React.FC<MessageParams> = ({
isFocused,
isSelfTemporaryGuest,
isLastDeliveredMessage,
lastMessageInGroup,
shouldShowInvitePeople,
hideHeader,
hasReadReceiptsTurnedOn,
Expand Down Expand Up @@ -184,6 +185,7 @@ export const MessageWrapper: React.FC<MessageParams> = ({
return (
<ContentMessageComponent
message={message}
lastMessageInGroup={lastMessageInGroup}
findMessage={findMessage}
conversation={conversation}
hideHeader={hideHeader}
Expand Down
1 change: 1 addition & 0 deletions src/script/components/MessagesList/Message/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export interface MessageParams extends MessageActions {
conversation: Conversation;
hasReadReceiptsTurnedOn: boolean;
isLastDeliveredMessage: boolean;
lastMessageInGroup: BaseMessage;
isSelfTemporaryGuest: boolean;
message: BaseMessage;
/** whether the message should display the user avatar and user name before the actual content */
Expand Down
3 changes: 3 additions & 0 deletions src/script/components/MessagesList/MessageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ export const MessagesList: FC<MessagesListParams> = ({
return messages.map(message => {
const isLastDeliveredMessage = lastDeliveredMessage?.id === message.id;

const lastMessageInGroup = group.messages[messages.length - 1];

const visibleCallback = getVisibleCallback(conversation, message);

const key = `${message.id || 'message'}-${message.timestamp()}`;
Expand All @@ -276,6 +278,7 @@ export const MessagesList: FC<MessagesListParams> = ({
key={key}
onVisible={visibleCallback}
message={message}
lastMessageInGroup={lastMessageInGroup}
hideHeader={message.timestamp() !== firstMessageTimestamp}
messageActions={messageActions}
conversation={conversation}
Expand Down
Loading