summary refs log tree commit diff
path: root/webclient/app-controller.js
diff options
context:
space:
mode:
authorPaul "LeoNerd" Evans <paul@matrix.org>2014-09-12 17:20:06 +0100
committerPaul "LeoNerd" Evans <paul@matrix.org>2014-09-12 17:20:06 +0100
commit1c51c8ab7d331f6be3a8fd14d6d1a40e0a2d3c29 (patch)
tree74528065c199aa426611c41a1351f54e35fa3f3a /webclient/app-controller.js
parentInitial hack at some RoomMemberStore unit tests (diff)
parentMake the state resolution use actual power levels rather than taking them fro... (diff)
downloadsynapse-1c51c8ab7d331f6be3a8fd14d6d1a40e0a2d3c29.tar.xz
Merge remote-tracking branch 'origin/develop' into test-sqlite-memory
Conflicts:
	synapse/storage/pdu.py
Diffstat (limited to 'webclient/app-controller.js')
-rw-r--r--webclient/app-controller.js30
1 files changed, 18 insertions, 12 deletions
diff --git a/webclient/app-controller.js b/webclient/app-controller.js
index feda0f6b57..6c3759878b 100644
--- a/webclient/app-controller.js
+++ b/webclient/app-controller.js
@@ -21,8 +21,8 @@ limitations under the License.
 'use strict';
 
 angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'eventStreamService'])
-.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', '$timeout', '$animate', 'matrixService', 'mPresence', 'eventStreamService', 'matrixPhoneService',
-                               function($scope, $location, $rootScope, $timeout, $animate, matrixService, mPresence, eventStreamService, matrixPhoneService) {
+.controller('MatrixWebClientController', ['$scope', '$location', '$rootScope', '$timeout', '$animate', 'matrixService', 'mPresence', 'eventStreamService', 'eventHandlerService', 'matrixPhoneService',
+                               function($scope, $location, $rootScope, $timeout, $animate, matrixService, mPresence, eventStreamService, eventHandlerService, matrixPhoneService) {
          
     // Check current URL to avoid to display the logout button on the login page
     $scope.location = $location.path();
@@ -73,7 +73,10 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
         // Clean permanent data
         matrixService.setConfig({});
         matrixService.saveConfig();
-        
+
+        // Reset cached data
+        eventHandlerService.reset();
+
         // And go to the login page
         $location.url("login");
     };
@@ -135,9 +138,9 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
     });
 
     $rootScope.$on(matrixPhoneService.INCOMING_CALL_EVENT, function(ngEvent, call) {
-        console.trace("incoming call");
+        console.log("incoming call");
         if ($rootScope.currentCall && $rootScope.currentCall.state != 'ended') {
-            console.trace("rejecting call because we're already in a call");
+            console.log("rejecting call because we're already in a call");
             call.hangup();
             return;
         }
@@ -146,6 +149,13 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
         $rootScope.currentCall = call;
     });
 
+    $rootScope.$on(matrixPhoneService.REPLACED_CALL_EVENT, function(ngEvent, oldCall, newCall) {
+        console.log("call ID "+oldCall.call_id+" has been replaced by call ID "+newCall.call_id+"!");
+        newCall.onError = $scope.onCallError;
+        newCall.onHangup = $scope.onCallHangup;
+        $rootScope.currentCall = newCall;
+    });
+
     $scope.answerCall = function() {
         $rootScope.currentCall.answer();
     };
@@ -160,13 +170,9 @@ angular.module('MatrixWebClientController', ['matrixService', 'mPresence', 'even
 
     $rootScope.onCallHangup = function(call) {
         if (call == $rootScope.currentCall) {
-            $timeout(function() {
-                var icon = angular.element('#callEndedIcon');
-                $animate.addClass(icon, 'callIconRotate');
-                $timeout(function(){
-                    $rootScope.currentCall = undefined;
-                }, 4070);
-            }, 100);
+            $timeout(function(){
+                if (call == $rootScope.currentCall) $rootScope.currentCall = undefined;
+            }, 4070);
         }
     }
 }]);