Bug 1109511: listen for the 'delete' event to update the toolbar icon when a room is deleted. r=Niko a=lsblakk
--- 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");