Skip to content

Commit

Permalink
Use older timestamp so that more messages are marked as read
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusbsilva137 committed Oct 13, 2023
1 parent 230e653 commit dde591c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/meteor/server/lib/readMessages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { callbacks } from '../../lib/callbacks';
export async function readMessages(rid: IRoom['_id'], uid: IUser['_id'], readThreads: boolean): Promise<void> {
await callbacks.run('beforeReadMessages', rid, uid);

const projection = { ls: 1, tunread: 1, alert: 1, _updatedAt: 1 };
const projection = { ls: 1, tunread: 1, alert: 1, ts: 1 };
const sub = await Subscriptions.findOneByRoomIdAndUserId(rid, uid, { projection });
if (!sub) {
throw new Error('error-invalid-subscription');
Expand All @@ -19,6 +19,6 @@ export async function readMessages(rid: IRoom['_id'], uid: IUser['_id'], readThr

await NotificationQueue.clearQueueByUserId(uid);

const lastSeen = sub.ls || sub._updatedAt;
const lastSeen = sub.ls || sub.ts;
callbacks.runAsync('afterReadMessages', rid, { uid, lastSeen });
}

0 comments on commit dde591c

Please sign in to comment.