Remap tabs when open/close/activated #179
This commit is contained in:
parent
fb50da6d92
commit
76fc91be9a
1 changed files with 15 additions and 8 deletions
23
index.js
23
index.js
|
@ -129,25 +129,20 @@ const ContainerService = {
|
||||||
}
|
}
|
||||||
|
|
||||||
tabs.on("open", tab => {
|
tabs.on("open", tab => {
|
||||||
const userContextId = this._getUserContextIdFromTab(tab);
|
|
||||||
if (userContextId) {
|
|
||||||
++this._identitiesState[userContextId].openTabs;
|
|
||||||
}
|
|
||||||
this._hideAllPanels();
|
this._hideAllPanels();
|
||||||
this._restyleTab(tab);
|
this._restyleTab(tab);
|
||||||
|
this._remapTab(tab);
|
||||||
});
|
});
|
||||||
|
|
||||||
tabs.on("close", tab => {
|
tabs.on("close", tab => {
|
||||||
const userContextId = this._getUserContextIdFromTab(tab);
|
|
||||||
if (userContextId && this._identitiesState[userContextId].openTabs) {
|
|
||||||
--this._identitiesState[userContextId].openTabs;
|
|
||||||
}
|
|
||||||
this._hideAllPanels();
|
this._hideAllPanels();
|
||||||
|
this._remapTab(tab);
|
||||||
});
|
});
|
||||||
|
|
||||||
tabs.on("activate", tab => {
|
tabs.on("activate", tab => {
|
||||||
this._hideAllPanels();
|
this._hideAllPanels();
|
||||||
this._restyleActiveTab(tab).catch(() => {});
|
this._restyleActiveTab(tab).catch(() => {});
|
||||||
|
this._remapTab(tab);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Modify CSS and other stuff for each window.
|
// Modify CSS and other stuff for each window.
|
||||||
|
@ -318,11 +313,23 @@ const ContainerService = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this._identitiesState[userContextId] = this._createIdentityState();
|
this._identitiesState[userContextId] = this._createIdentityState();
|
||||||
|
this._remapTabsFromUserContextId(userContextId);
|
||||||
|
},
|
||||||
|
|
||||||
|
_remapTabsFromUserContextId(userContextId) {
|
||||||
|
this._identitiesState[userContextId].openTabs = 0;
|
||||||
this._containerTabIterator(userContextId, () => {
|
this._containerTabIterator(userContextId, () => {
|
||||||
++this._identitiesState[userContextId].openTabs;
|
++this._identitiesState[userContextId].openTabs;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_remapTab(tab) {
|
||||||
|
const userContextId = this._getUserContextIdFromTab(tab);
|
||||||
|
if (userContextId) {
|
||||||
|
this._remapTabsFromUserContextId(userContextId);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_isKnownContainer(userContextId) {
|
_isKnownContainer(userContextId) {
|
||||||
return userContextId in this._identitiesState;
|
return userContextId in this._identitiesState;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Reference in a new issue