Bug 1109511: listen for the 'delete' event to update the toolbar icon when a room is deleted. r=Niko a=lsblakk
authorMike de Boer <mdeboer@mozilla.com>
Fri, 12 Dec 2014 16:39:17 +0100
changeset 242444 0891d8dfe59452f6761c0679f189b759ef5c4b23
parent 242443 205354ee00bb368059d2de05c096d6d46cda3564
child 242445 9d18b94c716efdd0a98f4e6a2396a88a2a9d0d99
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNiko, lsblakk
bugs1109511
milestone36.0a2
Bug 1109511: listen for the 'delete' event to update the toolbar icon when a room is deleted. r=Niko a=lsblakk
browser/components/loop/LoopRooms.jsm
browser/components/loop/MozLoopService.jsm
--- a/browser/components/loop/LoopRooms.jsm
+++ b/browser/components/loop/LoopRooms.jsm
@@ -130,17 +130,17 @@ let LoopRoomsInternal = {
 
   /**
    * @var {Number} participantsCount The total amount of participants currently
    *                                 inside all rooms.
    */
   get participantsCount() {
     let count = 0;
     for (let room of this.rooms.values()) {
-      if (!("participants" in room)) {
+      if (room.deleted || !("participants" in room)) {
         continue;
       }
       count += room.participants.length;
     }
     return count;
   },
 
   /**
--- a/browser/components/loop/MozLoopService.jsm
+++ b/browser/components/loop/MozLoopService.jsm
@@ -1052,21 +1052,23 @@ this.MozLoopService = {
       gFxAEnabled = Services.prefs.getBoolPref("loop.fxa.enabled");
       if (!gFxAEnabled) {
         yield this.logOutFromFxA();
       }
     }
 
     // The Loop toolbar button should change icon when the room participant count
     // changes from 0 to something.
-    const onRoomsChange = () => {
-      MozLoopServiceInternal.notifyStatusChanged();
+    const onRoomsChange = (e) => {
+      // Pass the event name as notification reason for better logging.
+      MozLoopServiceInternal.notifyStatusChanged("room-" + e);
     };
     LoopRooms.on("add", onRoomsChange);
     LoopRooms.on("update", onRoomsChange);
+    LoopRooms.on("delete", onRoomsChange);
     LoopRooms.on("joined", (e, room, participant) => {
       // Don't alert if we're in the doNotDisturb mode, or the participant
       // is the owner - the content code deals with the rest of the sounds.
       if (MozLoopServiceInternal.doNotDisturb || participant.owner) {
         return;
       }
 
       let window = gWM.getMostRecentWindow("navigator:browser");