mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-13 18:50:29 +03:00
Remove unused javascript (#2470)
Some checks are pending
Deploy to Netlify (dev) / Deploy to Netlify (push) Waiting to run
Some checks are pending
Deploy to Netlify (dev) / Deploy to Netlify (push) Waiting to run
This commit is contained in:
parent
399b1a373e
commit
90ca8ca2c5
214 changed files with 341 additions and 8768 deletions
26
src/app/utils/notifications.ts
Normal file
26
src/app/utils/notifications.ts
Normal 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
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue