mirror of
https://github.com/oxen-io/session-desktop.git
synced 2023-12-14 02:12:57 +01:00
revert prev changes + marking read now based on received_at
This commit is contained in:
parent
14ef4cd39a
commit
c38d2a5ea7
|
@ -729,8 +729,8 @@ class MessageInner extends React.PureComponent<MessageRegularProps, State> {
|
|||
divClasses.push('flash-green-once');
|
||||
}
|
||||
|
||||
const onVisible = (inView: boolean) => {
|
||||
if (inView && shouldMarkReadWhenVisible && window.isFocused()) {
|
||||
const onVisible = (inView: boolean | Object) => {
|
||||
if (inView === true && shouldMarkReadWhenVisible && window.isFocused()) {
|
||||
// mark the message as read.
|
||||
// this will trigger the expire timer.
|
||||
void markRead(Date.now());
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import React from 'react';
|
||||
import { useFocus } from '../../hooks/useFocus';
|
||||
import { InView } from 'react-intersection-observer';
|
||||
import { InView, useInView } from 'react-intersection-observer';
|
||||
|
||||
type ReadableMessageProps = {
|
||||
children: React.ReactNode;
|
||||
|
@ -11,6 +11,22 @@ type ReadableMessageProps = {
|
|||
};
|
||||
|
||||
export const ReadableMessage = (props: ReadableMessageProps) => {
|
||||
/*const { ref, inView, entry } = useInView({
|
||||
threshold: 1,
|
||||
delay: 200,
|
||||
triggerOnce: true,
|
||||
trackVisibility: true,
|
||||
});
|
||||
|
||||
const { onChange } = props;
|
||||
useFocus(() => onChange(inView));
|
||||
|
||||
return (
|
||||
<div ref={ref} id={props.id} onContextMenu={props.onContextMenu} className={props.className} onChange={onChange}>
|
||||
{props.children}
|
||||
</div>
|
||||
)*/
|
||||
|
||||
const { onChange } = props;
|
||||
useFocus(onChange);
|
||||
|
||||
|
|
|
@ -92,7 +92,6 @@ export interface ConversationAttributes {
|
|||
triggerNotificationsFor: ConversationNotificationSettingType;
|
||||
isTrustedForAttachmentDownload: boolean;
|
||||
isPinned: boolean;
|
||||
lastReadTimestamp: number;
|
||||
}
|
||||
|
||||
export interface ConversationAttributesOptionals {
|
||||
|
@ -161,7 +160,6 @@ export const fillConvoAttributesWithDefaults = (
|
|||
triggerNotificationsFor: 'all', // if the settings is not set in the db, this is the default
|
||||
isTrustedForAttachmentDownload: false, // we don't trust a contact until we say so
|
||||
isPinned: false,
|
||||
lastReadTimestamp: 0,
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -190,13 +188,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
this.updateLastMessage = _.throttle(this.bouncyUpdateLastMessage.bind(this), 1000);
|
||||
this.throttledNotify = _.debounce(this.notify, 500, { maxWait: 1000 });
|
||||
//start right away the function is called, and wait 1sec before calling it again
|
||||
this.markRead = (readAt: number) => {
|
||||
const lastReadTimestamp = this.get('lastReadTimestamp');
|
||||
if (readAt > lastReadTimestamp) {
|
||||
this.set('lastReadTimestamp', readAt);
|
||||
}
|
||||
_.debounce(this.markReadBouncy, 1000, { leading: true });
|
||||
}
|
||||
this.markRead = _.debounce(this.markReadBouncy, 1000, { leading: true });
|
||||
// Listening for out-of-band data updates
|
||||
|
||||
this.typingRefreshTimer = null;
|
||||
|
@ -910,9 +902,6 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
|
|||
}
|
||||
|
||||
public async markReadBouncy(newestUnreadDate: number, providedOptions: any = {}) {
|
||||
if (this.get('lastReadTimestamp') >= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const options = providedOptions || {};
|
||||
_.defaults(options, { sendReadReceipts: true });
|
||||
|
|
|
@ -1047,7 +1047,7 @@ export class MessageModel extends Backbone.Model<MessageAttributes> {
|
|||
public async markRead(readAt: number) {
|
||||
this.markReadNoCommit(readAt);
|
||||
|
||||
this.getConversation()?.markRead(readAt);
|
||||
this.getConversation()?.markRead(this.attributes.received_at);
|
||||
|
||||
await this.commit();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue