Commit cd731ed6 authored by JC Brand's avatar JC Brand

Some refactoring to make plugins easier.

- Refactored sound notification to make it a bit more generic
- Split up onMessage
parent 4ebed3c9
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
test_utils.openChatRoom('lounge', 'localhost', 'dummy'); test_utils.openChatRoom('lounge', 'localhost', 'dummy');
spyOn(converse, 'emit'); spyOn(converse, 'emit');
converse.play_sounds = true; converse.play_sounds = true;
spyOn(converse, 'playNotification'); spyOn(converse, 'notifyOfNewMessage');
var view = this.chatboxviews.get('lounge@localhost'); var view = this.chatboxviews.get('lounge@localhost');
if (!view.$el.find('.chat-area').length) { view.renderChatArea(); } if (!view.$el.find('.chat-area').length) { view.renderChatArea(); }
var text = 'This message will play a sound because it mentions dummy'; var text = 'This message will play a sound because it mentions dummy';
...@@ -207,7 +207,7 @@ ...@@ -207,7 +207,7 @@
type: 'groupchat' type: 'groupchat'
}).c('body').t(text); }).c('body').t(text);
view.onChatRoomMessage(message.nodeTree); view.onChatRoomMessage(message.nodeTree);
expect(converse.playNotification).toHaveBeenCalled(); expect(converse.notifyOfNewMessage).toHaveBeenCalled();
text = "This message won't play a sound"; text = "This message won't play a sound";
message = $msg({ message = $msg({
...@@ -217,7 +217,7 @@ ...@@ -217,7 +217,7 @@
type: 'groupchat' type: 'groupchat'
}).c('body').t(text); }).c('body').t(text);
view.onChatRoomMessage(message.nodeTree); view.onChatRoomMessage(message.nodeTree);
expect(converse.playNotification, 1); expect(converse.notifyOfNewMessage, 1);
converse.play_sounds = false; converse.play_sounds = false;
text = "This message won't play a sound because it is sent by dummy"; text = "This message won't play a sound because it is sent by dummy";
...@@ -228,7 +228,7 @@ ...@@ -228,7 +228,7 @@
type: 'groupchat' type: 'groupchat'
}).c('body').t(text); }).c('body').t(text);
view.onChatRoomMessage(message.nodeTree); view.onChatRoomMessage(message.nodeTree);
expect(converse.playNotification, 1); expect(converse.notifyOfNewMessage, 1);
converse.play_sounds = false; converse.play_sounds = false;
}.bind(converse)); }.bind(converse));
......
This diff is collapsed.
...@@ -916,7 +916,7 @@ ...@@ -916,7 +916,7 @@
} }
this.model.createMessage($message, $delay, archive_id); this.model.createMessage($message, $delay, archive_id);
if (!delayed && sender !== this.model.get('nick') && (new RegExp("\\b"+this.model.get('nick')+"\\b")).test(body)) { if (!delayed && sender !== this.model.get('nick') && (new RegExp("\\b"+this.model.get('nick')+"\\b")).test(body)) {
converse.playNotification(); converse.notifyOfNewMessage();
} }
if (sender !== this.model.get('nick')) { if (sender !== this.model.get('nick')) {
// We only emit an event if it's not our own message // We only emit an event if it's not our own message
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment