Remove unused javascript (#2470)
Some checks are pending
Deploy to Netlify (dev) / Deploy to Netlify (push) Waiting to run

This commit is contained in:
Ajay Bura 2025-08-29 15:04:52 +05:30 committed by GitHub
parent 399b1a373e
commit 90ca8ca2c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
214 changed files with 341 additions and 8768 deletions

View file

@ -0,0 +1,26 @@
import { MatrixClient, ReceiptType } from 'matrix-js-sdk';
export async function markAsRead(mx: MatrixClient, roomId: string, privateReceipt: boolean) {
const room = mx.getRoom(roomId);
if (!room) return;
const timeline = room.getLiveTimeline().getEvents();
const readEventId = room.getEventReadUpTo(mx.getUserId()!);
const getLatestValidEvent = () => {
for (let i = timeline.length - 1; i >= 0; i -= 1) {
const latestEvent = timeline[i];
if (latestEvent.getId() === readEventId) return null;
if (!latestEvent.isSending()) return latestEvent;
}
return null;
};
if (timeline.length === 0) return;
const latestEvent = getLatestValidEvent();
if (latestEvent === null) return;
await mx.sendReadReceipt(
latestEvent,
privateReceipt ? ReceiptType.ReadPrivate : ReceiptType.Read
);
}