From 3fbdce6901a2797e8a6cedb2254bb4d9e0cdf11f Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 27 Aug 2020 18:06:25 -0500 Subject: [PATCH] Chats: mark as read when the input is focused --- app/soapbox/features/chats/components/chat_window.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/soapbox/features/chats/components/chat_window.js b/app/soapbox/features/chats/components/chat_window.js index fed5cb525..af9f9bcee 100644 --- a/app/soapbox/features/chats/components/chat_window.js +++ b/app/soapbox/features/chats/components/chat_window.js @@ -99,6 +99,15 @@ class ChatWindow extends ImmutablePureComponent { if (oldState !== newState && newState === 'open') this.focusInput(); + + const markReadConditions = [ + () => this.props.chat !== undefined, + () => document.activeElement === this.inputElem, + () => this.props.chat.get('unread') > 0, + ]; + + if (markReadConditions.every(c => c() === true)) + this.handleReadChat(); } render() {