From fa606b8040d58a3d17a465951db89fe6ee6c3a76 Mon Sep 17 00:00:00 2001 From: crockwave Date: Wed, 9 Sep 2020 19:01:25 -0500 Subject: [PATCH] Render chat unread count update in tab even when tab doesn't have focus Render chat unread count update even when chat box has focus Render chat unread count update on page load --- app/soapbox/actions/chats.js | 1 + app/soapbox/components/helmet.js | 1 + .../features/chats/components/chat_box.js | 20 +++++++++---------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/app/soapbox/actions/chats.js b/app/soapbox/actions/chats.js index 30558368c..4e51d776a 100644 --- a/app/soapbox/actions/chats.js +++ b/app/soapbox/actions/chats.js @@ -30,6 +30,7 @@ export function fetchChats() { dispatch({ type: CHATS_FETCH_REQUEST }); return api(getState).get('/api/v1/pleroma/chats').then(({ data }) => { dispatch({ type: CHATS_FETCH_SUCCESS, chats: data }); + chatsNotification(data); }).catch(error => { dispatch({ type: CHATS_FETCH_FAIL, error }); }); diff --git a/app/soapbox/components/helmet.js b/app/soapbox/components/helmet.js index f3bff8740..c9c1eb5a6 100644 --- a/app/soapbox/components/helmet.js +++ b/app/soapbox/components/helmet.js @@ -36,6 +36,7 @@ class SoapboxHelmet extends React.Component { {children} diff --git a/app/soapbox/features/chats/components/chat_box.js b/app/soapbox/features/chats/components/chat_box.js index 12b28d513..b09e1eb94 100644 --- a/app/soapbox/features/chats/components/chat_box.js +++ b/app/soapbox/features/chats/components/chat_box.js @@ -80,16 +80,16 @@ class ChatBox extends ImmutablePureComponent { onSetInputRef(el); }; - componentDidUpdate(prevProps) { - const markReadConditions = [ - () => this.props.chat !== undefined, - () => document.activeElement === this.inputElem, - () => this.props.chat.get('unread') > 0, - ]; - - if (markReadConditions.every(c => c() === true)) - this.markRead(); - } + // componentDidUpdate(prevProps) { + // const markReadConditions = [ + // () => this.props.chat !== undefined, + // () => document.activeElement === this.inputElem, + // () => this.props.chat.get('unread') > 0, + // ]; + // + // if (markReadConditions.every(c => c() === true)) + // this.markRead(); + // } render() { const { chatMessageIds, chatId, intl } = this.props;