From dce1875de45e96ef8476cc3898525b803d8dcc23 Mon Sep 17 00:00:00 2001 From: or-else Date: Wed, 20 Nov 2019 11:44:15 +0300 Subject: [PATCH] simplify handling of new message notifications --- src/views/tinode-web.jsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/views/tinode-web.jsx b/src/views/tinode-web.jsx index a5827eec..551e44dd 100644 --- a/src/views/tinode-web.jsx +++ b/src/views/tinode-web.jsx @@ -558,21 +558,14 @@ class TinodeWeb extends React.Component { const archived = topic && topic.isArchived(); // New message received. Maybe the message is from the current user, then unread is 0. - if (cont.unread > 0) { - if (document.hidden) { - if (this.state.messageSounds && !archived) { - POP_SOUND.play(); - } - this.resetContactList(); - + if (cont.unread > 0 && this.state.messageSounds && !archived) { // Skip update if the topic is currently open, otherwise the badge will annoyingly flash. - } else if (this.state.topicSelected != cont.topic) { - if (this.state.messageSounds && !archived) { - POP_SOUND.play(); - } - this.resetContactList(); + if (document.hidden || this.state.topicSelected != cont.topic) { + POP_SOUND.play(); } } + // Reorder contact list to use possibly updated 'touched'. + this.resetContactList(); } else if (what == 'recv') { // Explicitly ignoring "recv" -- it causes no visible updates to contact list. } else if (what == 'gone' || what == 'unsub') {