From c3595f9cb4a508f8b5ec602d5cfe7a465df42f96 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Mon, 4 Apr 2016 10:37:36 -0400 Subject: [PATCH] bug fixes and chat sounds on by default --- app/assets/javascripts/src/Metamaps.js.erb | 2 ++ app/assets/javascripts/src/views/chatView.js.erb | 12 ++++++------ app/assets/javascripts/src/views/room.js | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.js.erb b/app/assets/javascripts/src/Metamaps.js.erb index 278a1e8b..c49e6801 100644 --- a/app/assets/javascripts/src/Metamaps.js.erb +++ b/app/assets/javascripts/src/Metamaps.js.erb @@ -2239,6 +2239,7 @@ Metamaps.Realtime = { invitedToCall: function (inviter) { var self = Metamaps.Realtime; + self.room.chat.sound.stop('sessioninvite'); self.room.chat.sound.play('sessioninvite'); var username = self.mappersOnMap[inviter].name; @@ -2251,6 +2252,7 @@ Metamaps.Realtime = { invitedToJoin: function (inviter) { var self = Metamaps.Realtime; + self.room.chat.sound.stop('sessioninvite'); self.room.chat.sound.play('sessioninvite'); var username = self.mappersOnMap[inviter].name; diff --git a/app/assets/javascripts/src/views/chatView.js.erb b/app/assets/javascripts/src/views/chatView.js.erb index 174d54bb..7a1e7f8e 100644 --- a/app/assets/javascripts/src/views/chatView.js.erb +++ b/app/assets/javascripts/src/views/chatView.js.erb @@ -38,7 +38,7 @@ Metamaps.Views.chatView = (function () { this.$participants = $('
'); this.$conversationInProgress = $('
LIVE LEAVEJOIN
'); this.$chatHeader = $('
CHAT
'); - this.$soundToggle = $('
'); + this.$soundToggle = $('
'); this.$messages = $('
'); this.$container = $('
'); }, @@ -109,7 +109,7 @@ Metamaps.Views.chatView = (function () { this.$unread.html(this.unreadMessages); this.$unread.show(); }, - addMessage: function(message, isInitial) { + addMessage: function(message, isInitial, wasMe) { if (!this.isOpen && !isInitial) Private.incrementUnread.call(this); @@ -133,7 +133,7 @@ Metamaps.Views.chatView = (function () { this.$messages.append($html); if (!isInitial) this.scrollMessages(200); - if (!isInitial && this.alertSound) this.sound.play('receivechat'); + if (!wasMe && !isInitial && this.alertSound) this.sound.play('receivechat'); }, initialMessages: function() { var messages = this.messages.models; @@ -207,7 +207,7 @@ Metamaps.Views.chatView = (function () { this.messages = messages; // backbone collection this.isOpen = false; - this.alertSound = false; // whether to play sounds on arrival of new messages or not + this.alertSound = true; // whether to play sounds on arrival of new messages or not this.cursorsShowing = true; this.videosShowing = true; this.unreadMessages = 0; @@ -289,9 +289,9 @@ Metamaps.Views.chatView = (function () { $(document).trigger(chatView.events.openTray); } - chatView.prototype.addMessage = function(message, isInitial) { + chatView.prototype.addMessage = function(message, isInitial, wasMe) { this.messages.add(message); - Private.addMessage.call(this, message, isInitial); + Private.addMessage.call(this, message, isInitial, wasMe); } chatView.prototype.scrollMessages = function(duration) { diff --git a/app/assets/javascripts/src/views/room.js b/app/assets/javascripts/src/views/room.js index a6f0eec8..4595c3cb 100644 --- a/app/assets/javascripts/src/views/room.js +++ b/app/assets/javascripts/src/views/room.js @@ -164,7 +164,7 @@ Metamaps.Views.room = (function () { }); m.save(null, { success: function (model, response) { - self.addMessages(new Metamaps.Backbone.MessageCollection(model), true); + self.addMessages(new Metamaps.Backbone.MessageCollection(model), false, true); $(document).trigger(room.events.newMessage, [model]); }, error: function (model, response) { @@ -175,11 +175,11 @@ Metamaps.Views.room = (function () { // they should be instantiated as backbone models before they get // passed to this function - room.prototype.addMessages = function (messages, isInitial) { + room.prototype.addMessages = function (messages, isInitial, wasMe) { var self = this; messages.models.forEach(function (message) { - self.chat.addMessage(message, isInitial); + self.chat.addMessage(message, isInitial, wasMe); }); }