Remap tabs when open/close/activated #179

This commit is contained in:
baku 2017-02-17 10:04:54 +01:00
parent fb50da6d92
commit 76fc91be9a

View file

@ -129,25 +129,20 @@ const ContainerService = {
}
tabs.on("open", tab => {
const userContextId = this._getUserContextIdFromTab(tab);
if (userContextId) {
++this._identitiesState[userContextId].openTabs;
}
this._hideAllPanels();
this._restyleTab(tab);
this._remapTab(tab);
});
tabs.on("close", tab => {
const userContextId = this._getUserContextIdFromTab(tab);
if (userContextId && this._identitiesState[userContextId].openTabs) {
--this._identitiesState[userContextId].openTabs;
}
this._hideAllPanels();
this._remapTab(tab);
});
tabs.on("activate", tab => {
this._hideAllPanels();
this._restyleActiveTab(tab).catch(() => {});
this._remapTab(tab);
});
// Modify CSS and other stuff for each window.
@ -318,11 +313,23 @@ const ContainerService = {
}
this._identitiesState[userContextId] = this._createIdentityState();
this._remapTabsFromUserContextId(userContextId);
},
_remapTabsFromUserContextId(userContextId) {
this._identitiesState[userContextId].openTabs = 0;
this._containerTabIterator(userContextId, () => {
++this._identitiesState[userContextId].openTabs;
});
},
_remapTab(tab) {
const userContextId = this._getUserContextIdFromTab(tab);
if (userContextId) {
this._remapTabsFromUserContextId(userContextId);
}
},
_isKnownContainer(userContextId) {
return userContextId in this._identitiesState;
},