Hide/Show icon should be shown only if we have opened tabs

This commit is contained in:
baku
2017-01-09 11:05:13 +01:00
parent 76ad3fcb0f
commit 71725d829b
2 changed files with 47 additions and 1 deletions
+30 -1
View File
@@ -42,7 +42,35 @@ let ContainerService =
// Map of identities.
ContextualIdentityService.getIdentities().forEach(identity => {
this._identitiesState[identity.userContextId] = {hiddenTabUrls: []};
this._identitiesState[identity.userContextId] = {
hiddenTabUrls: [],
openTabs: 0,
};
});
// It can happen that this jsm is loaded after the opening a container tab.
for (let tab of tabs) {
let xulTab = viewFor(tab);
let userContextId = parseInt(xulTab.getAttribute('usercontextid') || 0, 10);
if (userContextId) {
++this._identitiesState[userContextId].openTabs;
}
}
tabs.on("open", tab => {
let xulTab = viewFor(tab);
let userContextId = parseInt(xulTab.getAttribute('usercontextid') || 0, 10);
if (userContextId) {
++this._identitiesState[userContextId].openTabs;
}
});
tabs.on("close", tab => {
let xulTab = viewFor(tab);
let userContextId = parseInt(xulTab.getAttribute('usercontextid') || 0, 10);
if (userContextId && this._identitiesState[userContextId].openTabs) {
--this._identitiesState[userContextId].openTabs;
}
});
// WebExtension startup
@@ -65,6 +93,7 @@ let ContainerService =
color: identity.color,
userContextId: identity.userContextId,
hasHiddenTabs: !!this._identitiesState[identity.userContextId].hiddenTabUrls.length,
hasOpenTabs: !!this._identitiesState[identity.userContextId].openTabs,
};
},