fix markRead using timestamp of now when scroll to bottom

pull/1792/head
audric 4 years ago
parent 1054278a54
commit 4b8778d071

@ -1185,7 +1185,6 @@ function updateToLokiSchemaVersion15(currentVersion, db) {
db.transaction(() => {
db.exec(`
DROP TABLE pairingAuthorisations;
DROP TABLE ${MESSAGES_FTS_TABLE};
DROP TRIGGER messages_on_delete;
DROP TRIGGER messages_on_update;
`);

@ -174,7 +174,7 @@ class SessionMessagesListContainerInner extends React.Component<Props> {
}
if ((forceIsOnBottom || this.getScrollOffsetBottomPx() === 0) && isElectronWindowFocused()) {
void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0).then(() => {
void conversation.markRead(Date.now()).then(() => {
window.inboxStore?.dispatch(markConversationFullyRead(conversationKey));
});
}
@ -372,7 +372,7 @@ class SessionMessagesListContainerInner extends React.Component<Props> {
const conversation = getConversationController().get(conversationKey);
if (isElectronWindowFocused()) {
void conversation.markRead(messagesProps[0].propsForMessage.receivedAt || 0).then(() => {
void conversation.markRead(Date.now()).then(() => {
window.inboxStore?.dispatch(markConversationFullyRead(conversationKey));
});
}

@ -198,7 +198,10 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
});
this.throttledNotify = _.debounce(this.notify, 500, { maxWait: 1000, trailing: true });
//start right away the function is called, and wait 1sec before calling it again
const markReadDebounced = _.debounce(this.markReadBouncy, 1000, { leading: true });
const markReadDebounced = _.debounce(this.markReadBouncy, 1000, {
leading: true,
trailing: true,
});
// tslint:disable-next-line: no-async-without-await
this.markRead = async (newestUnreadDate: number) => {
const lastReadTimestamp = this.lastReadTimestamp;
@ -972,7 +975,7 @@ export class ConversationModel extends Backbone.Model<ConversationAttributes> {
let allUnreadMessagesInConvo = (await this.getUnread()).models;
const oldUnreadNowRead = allUnreadMessagesInConvo.filter(
(message: any) => message.get('received_at') <= newestUnreadDate
message => (message.get('received_at') as number) <= newestUnreadDate
);
let read = [];

Loading…
Cancel
Save