Fix: sound notifications

This commit is contained in:
Sébastien Hut 2015-04-07 11:04:53 +02:00 committed by Sébastien Hut
parent 6eaa854ac4
commit 1dc027b0fd
3 changed files with 8 additions and 3 deletions

View File

@ -101,10 +101,15 @@ module.exports = HumanModel.define({
addMessage: function (message, notify) { addMessage: function (message, notify) {
message.owner = me.jid.bare; message.owner = me.jid.bare;
var self = this;
var mentions = []; var mentions = [];
var toMe = false;
this.resources.forEach(function (resource) { this.resources.forEach(function (resource) {
if (message.body.toLowerCase().indexOf('@' + resource.mucDisplayName) >= 0) { if (message.body.toLowerCase().indexOf('@' + resource.mucDisplayName) >= 0) {
mentions.push('@' + resource.mucDisplayName); mentions.push('@' + resource.mucDisplayName);
if (resource.mucDisplayName === self.nick)
toMe = true;
} }
}); });
if (message.body.toLowerCase().indexOf('@all') >= 0) { if (message.body.toLowerCase().indexOf('@all') >= 0) {
@ -120,7 +125,7 @@ module.exports = HumanModel.define({
if (notify && (!this.activeContact || (this.activeContact && !app.state.focused)) && !mine) { if (notify && (!this.activeContact || (this.activeContact && !app.state.focused)) && !mine) {
this.unreadCount++; this.unreadCount++;
if (message.mentions.length) { if (toMe) {
app.notifications.create(this.displayName, { app.notifications.create(this.displayName, {
body: message.body, body: message.body,
icon: this.avatar, icon: this.avatar,

View File

@ -210,7 +210,7 @@ module.exports = BasePage.extend({
this.model.lastSentMessage.correct(message); this.model.lastSentMessage.correct(message);
} else { } else {
var msgModel = new MessageModel(message); var msgModel = new MessageModel(message);
this.model.addMessage(msgModel); this.model.addMessage(msgModel, false);
this.model.lastSentMessage = msgModel; this.model.lastSentMessage = msgModel;
} }
} }

View File

@ -307,7 +307,7 @@ module.exports = BasePage.extend({
this.model.lastSentMessage.correct(message); this.model.lastSentMessage.correct(message);
} else { } else {
var msgModel = new MessageModel(message); var msgModel = new MessageModel(message);
this.model.addMessage(msgModel); this.model.addMessage(msgModel, false);
this.model.lastSentMessage = msgModel; this.model.lastSentMessage = msgModel;
} }
} }