From 744da99f30504e77cdd45d83e59348671048c158 Mon Sep 17 00:00:00 2001 From: or-else Date: Thu, 18 Jul 2019 13:35:39 +0300 Subject: [PATCH] don't play new message sound for achived topics --- src/views/tinode-web.jsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/views/tinode-web.jsx b/src/views/tinode-web.jsx index 82018216..46999266 100644 --- a/src/views/tinode-web.jsx +++ b/src/views/tinode-web.jsx @@ -532,15 +532,23 @@ class TinodeWeb extends React.Component { } else if (what == 'read') { this.resetContactList(); } else if (what == 'msg') { + // Check if the topic is archived. If so, don't play a sound. + const topic = this.tinode.getTopic(cont.topic); + const archived = topic && topic.isArchived(); + // New message received + if (document.hidden) { + if (this.state.messageSounds && !isArchived) { + POP_SOUND.play(); + } + this.resetContactList(); + // Skip update if the topic is currently open, otherwise the badge will annoyingly flash. - if (this.state.topicSelected != cont.topic) { - if (this.state.messageSounds) { + } else if (this.state.topicSelected != cont.topic) { + if (this.state.messageSounds !isArchived) { POP_SOUND.play(); } this.resetContactList(); - } else if (document.hidden && this.state.messageSounds) { - POP_SOUND.play(); } } else if (what == 'recv') { // Explicitly ignoring "recv" -- it causes no visible updates to contact list.