Re-register existing store when registering API

Signed-off-by: Lauri Nevala <lauri.nevala@gmail.com>
This commit is contained in:
Lauri Nevala committed 2021-02-16 10:04:36 +02:00
1 parent 3c78e2fce9
commit 2148b3e2c2
2 files changed
+6 -9

No files matched your search

+6 -8
View File
@@ -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 => {
-1
View File
@@ -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);
} }
} }
} }