Compare commits
1 Commits
fix-image-
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4ba7b9162d |
@@ -1,6 +1,6 @@
|
||||
import { MatrixClient, ReceiptType } from 'matrix-js-sdk';
|
||||
|
||||
export async function markAsRead(mx: MatrixClient, roomId: string, privateReceipt?: boolean) {
|
||||
export async function markAsRead(mx: MatrixClient, roomId: string, privateReceipt: boolean) {
|
||||
const room = mx.getRoom(roomId);
|
||||
if (!room) return;
|
||||
|
||||
@@ -19,15 +19,8 @@ export async function markAsRead(mx: MatrixClient, roomId: string, privateReceip
|
||||
const latestEvent = getLatestValidEvent();
|
||||
if (latestEvent === null) return;
|
||||
|
||||
const latestEventId = latestEvent.getId();
|
||||
if (!latestEventId) return;
|
||||
|
||||
// Set both the read receipt AND the fully_read marker
|
||||
// The fully_read marker is what persists your read position across sessions
|
||||
await mx.setRoomReadMarkers(
|
||||
roomId,
|
||||
latestEventId, // m.fully_read marker
|
||||
latestEvent, // m.read receipt event
|
||||
privateReceipt ? { receiptType: ReceiptType.ReadPrivate } : undefined
|
||||
await mx.sendReadReceipt(
|
||||
latestEvent,
|
||||
privateReceipt ? ReceiptType.ReadPrivate : ReceiptType.Read
|
||||
);
|
||||
}
|
||||
|
||||
@@ -27,24 +27,10 @@ if ('serviceWorker' in navigator) {
|
||||
? `${trimTrailingSlash(import.meta.env.BASE_URL)}/sw.js`
|
||||
: `/dev-sw.js?dev-sw`;
|
||||
|
||||
const sendSessionToSW = () => {
|
||||
navigator.serviceWorker.register(swUrl).then(() => {
|
||||
const session = getFallbackSession();
|
||||
pushSessionToSW(session?.baseUrl, session?.accessToken);
|
||||
};
|
||||
|
||||
navigator.serviceWorker.register(swUrl).then(sendSessionToSW);
|
||||
navigator.serviceWorker.ready.then(sendSessionToSW);
|
||||
window.addEventListener('load', sendSessionToSW);
|
||||
|
||||
// When returning from background
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'visible') {
|
||||
sendSessionToSW();
|
||||
}
|
||||
});
|
||||
|
||||
// When restored from bfcache (important on iOS)
|
||||
window.addEventListener('pageshow', sendSessionToSW);
|
||||
}
|
||||
|
||||
const mountApp = () => {
|
||||
|
||||
Reference in New Issue
Block a user