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

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

Loading…
Cancel
Save