don't play new message sound for achived topics

This commit is contained in:
or-else
2019-07-18 13:35:39 +03:00
parent 112ce08fde
commit 744da99f30
+12 -4
View File
@@ -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.