Browse Source

Throttle roomStatus event.

pull/12/head
Simon Eisenmann 11 years ago
parent
commit
7368d35502
  1. 21
      static/js/services/mediastream.js

21
static/js/services/mediastream.js

@ -28,7 +28,7 @@ define([
], function($, _, Connector, Api, WebRTC, tokens) { ], function($, _, Connector, Api, WebRTC, tokens) {
return ["$route", "$location", "$window", "visibility", "alertify", "$http", "safeApply", function($route, $location, $window, visibility, alertify, $http, safeApply) { return ["$route", "$location", "$window", "visibility", "alertify", "$http", "safeApply", "$timeout", function($route, $location, $window, visibility, alertify, $http, safeApply, $timeout) {
var globalcontext = $("#globalcontext").text(); var globalcontext = $("#globalcontext").text();
var context = JSON.parse(globalcontext); var context = JSON.parse(globalcontext);
@ -135,10 +135,23 @@ define([
$rootScope.roomlink = room ? mediaStream.url.room(room) : null; $rootScope.roomlink = room ? mediaStream.url.room(room) : null;
}); });
// Cache events, to avoid ui flicker during quick room changes.
var roomStatusCache = $rootScope.roomStatus;
var roomCache = null;
var roomCache2 = null;
$rootScope.$on("roomStatus", function(event, status) { $rootScope.$on("roomStatus", function(event, status) {
$rootScope.roomstatus = status ? true : false; roomStatusCache = status ? true : false;
var room = status ? $rootScope.roomid : null; roomCache = status ? $rootScope.roomid : null;
$rootScope.$broadcast("room", room); $timeout(function() {
if ($rootScope.roomstatus !== roomStatusCache) {
$rootScope.roomstatus = roomStatusCache;
console.log("set roomstsatus", roomStatusCache);
}
if (roomCache !== roomCache2) {
$rootScope.$broadcast("room", roomCache);
roomCache2 = roomCache;
}
}, 100);
}); });
visibility.afterPrerendering(function() { visibility.afterPrerendering(function() {

Loading…
Cancel
Save