mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Re-register existing store when registering API
Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
parent
3c78e2fce9
commit
2148b3e2c2
@ -23,6 +23,12 @@ export class ApiManager {
|
|||||||
|
|
||||||
registerApi(apiBase: string, api: KubeApi) {
|
registerApi(apiBase: string, api: KubeApi) {
|
||||||
if (!this.apis.has(apiBase)) {
|
if (!this.apis.has(apiBase)) {
|
||||||
|
this.stores.forEach((store) => {
|
||||||
|
if(store.api === api) {
|
||||||
|
this.stores.set(apiBase, store);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.apis.set(apiBase, api);
|
this.apis.set(apiBase, api);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,14 +49,6 @@ export class ApiManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStoreKey(oldKey: string) {
|
|
||||||
const store = this.stores.get(oldKey);
|
|
||||||
|
|
||||||
if (!store) return;
|
|
||||||
this.stores.delete(oldKey);
|
|
||||||
this.registerStore(store, [store.api]);
|
|
||||||
}
|
|
||||||
|
|
||||||
@action
|
@action
|
||||||
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
|
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
|
||||||
apis.forEach(api => {
|
apis.forEach(api => {
|
||||||
|
|||||||
@ -233,7 +233,6 @@ export class KubeApi<T extends KubeObject = any> {
|
|||||||
|
|
||||||
Object.defineProperty(this, "apiBase", { value: apiBase });
|
Object.defineProperty(this, "apiBase", { value: apiBase });
|
||||||
apiManager.registerApi(this.apiBase, this);
|
apiManager.registerApi(this.apiBase, this);
|
||||||
apiManager.updateStoreKey(this.objectConstructor.apiBase);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user