bug fixes and chat sounds on by default

This commit is contained in:
Connor Turland 2016-04-04 10:37:36 -04:00
parent ac762e0056
commit c3595f9cb4
3 changed files with 11 additions and 9 deletions

View file

@ -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;

View file

@ -38,7 +38,7 @@ Metamaps.Views.chatView = (function () {
this.$participants = $('<div class="participants"></div>');
this.$conversationInProgress = $('<div class="conversation-live">LIVE <span class="call-action leave" onclick="Metamaps.Realtime.leaveCall();">LEAVE</span><span class="call-action join" onclick="Metamaps.Realtime.joinCall();">JOIN</span></div>');
this.$chatHeader = $('<div class="chat-header">CHAT</div>');
this.$soundToggle = $('<div class="sound-toggle active"></div>');
this.$soundToggle = $('<div class="sound-toggle"></div>');
this.$messages = $('<div class="chat-messages"></div>');
this.$container = $('<div class="chat-box"></div>');
},
@ -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) {

View file

@ -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);
});
}