afe957015b
P1-5: Voice message playback speed toggle (0.75×/1×/1.5×/2×) in AudioContent.tsx P1-10: Private read receipts toggle in Privacy settings; wired to notifications.ts P1-3: Room filter input on Home tab and DMs tab (client-side, clears on tab switch) P1-8: Favorite rooms via m.favourite tag — Favorites section in Home sidebar, star/unstar in right-click menu P1-9: Room invite link + QR code in room settings (Share Room tile, api.qrserver.com QR) P1-6: Poll creation modal in composer (PollCreator.tsx, sends m.poll.start) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
29 lines
963 B
TypeScript
29 lines
963 B
TypeScript
import { MatrixClient, ReceiptType } from 'matrix-js-sdk';
|
|
import { getSettings } from '../state/settings';
|
|
|
|
export async function markAsRead(mx: MatrixClient, roomId: string, privateReceipt: boolean) {
|
|
const { privateReadReceipts } = getSettings();
|
|
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 || privateReadReceipts ? ReceiptType.ReadPrivate : ReceiptType.Read,
|
|
);
|
|
}
|