diff --git a/static/js/controllers/mediastreamcontroller.js b/static/js/controllers/mediastreamcontroller.js index ecad886c..b5294050 100644 --- a/static/js/controllers/mediastreamcontroller.js +++ b/static/js/controllers/mediastreamcontroller.js @@ -431,7 +431,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function }, 0); } - appData.e.triggerHandler("selfReceived", data); + appData.e.triggerHandler("selfReceived", [data]); }); @@ -489,6 +489,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function from: from }); }, 30000); + appData.e.triggerHandler("uiNotification", ["incoming", {from: from}]); }); mediaStream.webrtc.e.on("error", function(event, message, msgid) { @@ -740,6 +741,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function playSound.play("connect"); } }); + appData.e.triggerHandler("mainStatus", [status]); }); $scope.$on("notification", function(event, type, details) { @@ -765,6 +767,7 @@ define(['underscore', 'bigscreen', 'moment', 'sjcl', 'webrtc.adapter'], function playSound.play("question"); alertify.dialog.alert(message); } + appData.e.triggerHandler("uiNotification", [type, details]); }); $scope.$on("download", function(event, from, token) { diff --git a/static/js/directives/chat.js b/static/js/directives/chat.js index c58916c1..56d4004d 100644 --- a/static/js/directives/chat.js +++ b/static/js/directives/chat.js @@ -346,8 +346,13 @@ define(['underscore', 'text!partials/chat.html', 'text!partials/chatroom.html'], if (!subscope.isgroupchat && from !== sessionid) { playSound.play("message1"); desktopNotify.notify(translation._("Message from ") + displayName(from), message); + appData.e.triggerHandler("uiNotification", ["chatmessage", {from: from, message: message, first: subscope.firstmessage}]); } subscope.firstmessage = false; + } else { + if (!subscope.isgroupchat && from !== sessionid) { + appData.e.triggerHandler("uiNotification", ["chatmessage", {from: from, message: message, first: subscope.firstmessage}]); + } } }); chat(subscope, function(clonedElement, $scope) { diff --git a/static/js/services/appdata.js b/static/js/services/appdata.js index de688591..bb1cd513 100644 --- a/static/js/services/appdata.js +++ b/static/js/services/appdata.js @@ -20,9 +20,22 @@ */ define(["jquery"], function($) { - // appData.e events - // - authenticationChanged(userid) - // - selfReceived(self) + // appData.e events: + // subscribe these events with appData.e.on(eventname, function() {}). + // + // - authenticationChanged(event, userid) + // userid (string) : Public user id of the authenitcated user. + // + // - selfReceived(event, self) + // self (object) : Self document as received from API. + // + // - uiNotification(event, type, details) + // type (string) : Notification type (busy, reject, pickuptimeout, + // incomingbusy, incomingpickuptimeout, chatmessage) + // details (object) : Depends on event type. + // + // - mainStatus(event, status) + // status (string) : Status id (connected, waiting, ...) // appData return [function() {