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
better-alerts
crockwave 2020-09-09 19:01:25 -05:00
rodzic 76f8e02fb9
commit fa606b8040
3 zmienionych plików z 12 dodań i 10 usunięć

Wyświetl plik

@ -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 });
});

Wyświetl plik

@ -36,6 +36,7 @@ class SoapboxHelmet extends React.Component {
<Helmet
titleTemplate={this.addCounter(`%s | ${siteTitle}`)}
defaultTitle={this.addCounter(siteTitle)}
defer={false}
>
{children}
</Helmet>

Wyświetl plik

@ -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;