Introducing this._isKnownContainer()
This commit is contained in:
parent
1de7e0f593
commit
64d78e2d35
1 changed files with 23 additions and 30 deletions
53
index.js
53
index.js
|
@ -224,23 +224,23 @@ const ContainerService = {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_isKnownContainer(userContextId) {
|
||||||
|
return userContextId in this._identitiesState;
|
||||||
|
},
|
||||||
|
|
||||||
// Tabs management
|
// Tabs management
|
||||||
|
|
||||||
hideTabs(args) {
|
hideTabs(args) {
|
||||||
return new Promise((resolve, reject) => {
|
if (!("userContextId" in args)) {
|
||||||
if (!("userContextId" in args)) {
|
return Promise.reject("hideTabs must be called with userContextId argument.");
|
||||||
reject("hideTabs must be called with userContextId argument.");
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._remapTabsIfMissing(args.userContextId);
|
this._remapTabsIfMissing(args.userContextId);
|
||||||
|
if (!this._isKnownContainer(args.userContextId)) {
|
||||||
// We should check if this userContextId exists.
|
return Promise.resolve(null);
|
||||||
if (!(args.userContextId in this._identitiesState)) {
|
}
|
||||||
resolve(null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
return new Promise(resolve => {
|
||||||
this._containerTabIterator(args.userContextId, tab => {
|
this._containerTabIterator(args.userContextId, tab => {
|
||||||
const object = this._createTabObject(tab);
|
const object = this._createTabObject(tab);
|
||||||
|
|
||||||
|
@ -268,11 +268,8 @@ const ContainerService = {
|
||||||
}
|
}
|
||||||
|
|
||||||
this._remapTabsIfMissing(args.userContextId);
|
this._remapTabsIfMissing(args.userContextId);
|
||||||
|
if (!this._isKnownContainer(args.userContextId)) {
|
||||||
// We should check if this userContextId exists.
|
return Promise.resolve(null);
|
||||||
if (!(args.userContextId in this._identitiesState)) {
|
|
||||||
resolve(null);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
|
@ -337,20 +334,16 @@ const ContainerService = {
|
||||||
},
|
},
|
||||||
|
|
||||||
getTabs(args) {
|
getTabs(args) {
|
||||||
|
if (!("userContextId" in args)) {
|
||||||
|
return Promise.reject("getTabs must be called with userContextId argument.");
|
||||||
|
}
|
||||||
|
|
||||||
|
this._remapTabsIfMissing(args.userContextId);
|
||||||
|
if (!this._isKnownContainer(args.userContextId)) {
|
||||||
|
return Promise.resolve([]);
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
if (!("userContextId" in args)) {
|
|
||||||
reject("getTabs must be called with userContextId argument.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this._remapTabsIfMissing(args.userContextId);
|
|
||||||
|
|
||||||
// We should check if this userContextId exists.
|
|
||||||
if (!(args.userContextId in this._identitiesState)) {
|
|
||||||
resolve([]);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const list = [];
|
const list = [];
|
||||||
this._containerTabIterator(args.userContextId, tab => {
|
this._containerTabIterator(args.userContextId, tab => {
|
||||||
list.push(this._createTabObject(tab));
|
list.push(this._createTabObject(tab));
|
||||||
|
|
Loading…
Add table
Reference in a new issue