From 9924f087943653d3082a331a6eff4e19182bd627 Mon Sep 17 00:00:00 2001 From: sitting33 Date: Thu, 25 Apr 2024 16:07:41 +0200 Subject: [PATCH] Don't mark messages as read when window is not in focus --- components/app.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/components/app.js b/components/app.js index e6f5c77..488500e 100644 --- a/components/app.js +++ b/components/app.js @@ -734,7 +734,7 @@ export default class App extends Component { let prevReadReceipt = buf.prevReadReceipt; let receipts = { [ReceiptType.DELIVERED]: receiptFromMessage(msg) }; - if (this.state.activeBuffer !== buf.id) { + if (this.state.activeBuffer !== buf.id || !document.hasFocus()) { unread = Unread.union(unread, msgUnread); } else { receipts[ReceiptType.READ] = receiptFromMessage(msg); @@ -1943,6 +1943,11 @@ export default class App extends Component { } handleWindowFocus() { + if (this.state.activeBuffer) { + // TODO: only do this if scrolled at the bottom + this.markBufferAsRead(this.state.activeBuffer); + } + // When the user focuses gamja, send a PING to make sure we detect any // network errors ASAP