Skip to content

Commit

Permalink
Updated markAsRead to check both document.hidden and `document.ha…
Browse files Browse the repository at this point in the history
…sFocus()`
  • Loading branch information
really-not-lavacat committed Sep 8, 2024
1 parent 0cdbe0b commit ebc7b4b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/client/action/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import { MatrixClient } from "matrix-js-sdk";

export async function markAsRead(mx: MatrixClient, roomId: string) {
// Won't mark messages (or whatever in room) as read when tab inactive
if (document.hidden) return;
// or when browser is inactive (i.e. user interacts with some another app)
if (document.hidden || !document.hasFocus()) return;

const room = mx.getRoom(roomId);
if (!room) return;
Expand Down

0 comments on commit ebc7b4b

Please sign in to comment.