1
0
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:
Lauri Nevala 2021-02-16 10:04:36 +02:00
parent 3c78e2fce9
commit 2148b3e2c2
2 changed files with 6 additions and 9 deletions

View File

@ -23,6 +23,12 @@ export class ApiManager {
registerApi(apiBase: string, api: KubeApi) {
if (!this.apis.has(apiBase)) {
this.stores.forEach((store) => {
if(store.api === api) {
this.stores.set(apiBase, store);
}
});
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
registerStore(store: KubeObjectStore, apis: KubeApi[] = [store.api]) {
apis.forEach(api => {

View File

@ -233,7 +233,6 @@ export class KubeApi<T extends KubeObject = any> {
Object.defineProperty(this, "apiBase", { value: apiBase });
apiManager.registerApi(this.apiBase, this);
apiManager.updateStoreKey(this.objectConstructor.apiBase);
}
}
}