make sure unread is > 0 before playing a sound

This commit is contained in:
or-else
2019-11-20 11:40:36 +03:00
parent 99de97b2e1
commit 3392bf5ed7
7 changed files with 35 additions and 27 deletions
+13 -11
View File
@@ -557,19 +557,21 @@ class TinodeWeb extends React.Component {
const topic = this.tinode.getTopic(cont.topic); const topic = this.tinode.getTopic(cont.topic);
const archived = topic && topic.isArchived(); const archived = topic && topic.isArchived();
// New message received // New message received. Maybe the message is from the current user, then unread is 0.
if (document.hidden) { if (cont.unread > 0) {
if (this.state.messageSounds && !archived) { if (document.hidden) {
POP_SOUND.play(); if (this.state.messageSounds && !archived) {
} POP_SOUND.play();
this.resetContactList(); }
this.resetContactList();
// Skip update if the topic is currently open, otherwise the badge will annoyingly flash. // Skip update if the topic is currently open, otherwise the badge will annoyingly flash.
} else if (this.state.topicSelected != cont.topic) { } else if (this.state.topicSelected != cont.topic) {
if (this.state.messageSounds && !archived) { if (this.state.messageSounds && !archived) {
POP_SOUND.play(); POP_SOUND.play();
}
this.resetContactList();
} }
this.resetContactList();
} }
} else if (what == 'recv') { } else if (what == 'recv') {
// Explicitly ignoring "recv" -- it causes no visible updates to contact list. // Explicitly ignoring "recv" -- it causes no visible updates to contact list.
+12 -10
View File
@@ -4948,18 +4948,20 @@ var TinodeWeb = function (_React$Component) {
var topic = this.tinode.getTopic(cont.topic); var topic = this.tinode.getTopic(cont.topic);
var archived = topic && topic.isArchived(); var archived = topic && topic.isArchived();
if (document.hidden) { if (cont.unread > 0) {
if (this.state.messageSounds && !archived) { if (document.hidden) {
POP_SOUND.play(); if (this.state.messageSounds && !archived) {
} POP_SOUND.play();
}
this.resetContactList(); this.resetContactList();
} else if (this.state.topicSelected != cont.topic) { } else if (this.state.topicSelected != cont.topic) {
if (this.state.messageSounds && !archived) { if (this.state.messageSounds && !archived) {
POP_SOUND.play(); POP_SOUND.play();
} }
this.resetContactList(); this.resetContactList();
}
} }
} else if (what == 'recv') {} else if (what == 'gone' || what == 'unsub') { } else if (what == 'recv') {} else if (what == 'gone' || what == 'unsub') {
if (this.state.topicSelected == cont.topic) { if (this.state.topicSelected == cont.topic) {
+1 -1
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+6 -2
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long