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.