fix: read receipt on scrolling

pull/2335/head
Audric Ackermann 3 years ago
parent c22d7c2367
commit 72348d198e

@ -1,5 +1,6 @@
import React from 'react';
import { useSelector } from 'react-redux';
import styled from 'styled-components';
import { MessageRenderingProps } from '../../../../models/messageType';
import { PubKey } from '../../../../session/types';
import {
@ -19,6 +20,8 @@ type Props = {
messageId: string;
};
const StyledAuthorContainer = styled(Flex)`color: var(--color-text)`;
export const MessageAuthorText = (props: Props) => {
const selected = useSelector(state => getMessageAuthorProps(state as any, props.messageId));
@ -38,7 +41,7 @@ export const MessageAuthorText = (props: Props) => {
const displayedPubkey = authorProfileName ? PubKey.shorten(sender) : sender;
return (
<Flex container={true}>
<StyledAuthorContainer container={true}>
<ContactName
pubkey={displayedPubkey}
name={authorName}
@ -47,6 +50,6 @@ export const MessageAuthorText = (props: Props) => {
boldProfileName={true}
shouldShowPubkey={Boolean(isPublic)}
/>
</Flex>
</StyledAuthorContainer>
);
};

@ -144,17 +144,17 @@ export const ReadableMessage = (props: ReadableMessageProps) => {
const found = await Data.getMessageById(messageId);
if (found && Boolean(found.get('unread'))) {
const foundReceivedAt = found.get('received_at');
const foundSentAt = found.get('sent_at');
// mark the message as read.
// this will trigger the expire timer.
await found.markRead(Date.now());
// we should stack those and send them in a single message once every 5secs or something.
// this would be part of an redesign of the sending pipeline
if (foundReceivedAt) {
if (foundSentAt && selectedConversationKey) {
void getConversationController()
.get(found.id)
?.sendReadReceiptsIfNeeded([foundReceivedAt]);
.get(selectedConversationKey)
?.sendReadReceiptsIfNeeded([foundSentAt]);
}
}
}

Loading…
Cancel
Save