From 80352f5b3b5f4b65cd1cd74d6c084f4a193b95ff Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 11 Feb 2021 11:51:55 -0500 Subject: [PATCH] resolve review comments Signed-off-by: Sebastian Malton --- src/common/utils/common-types.ts | 1 + src/common/utils/index.ts | 1 + src/renderer/api/kube-watch-api.ts | 12 ++++++------ .../components/+namespaces/namespace.store.ts | 6 +----- src/renderer/utils/index.ts | 2 -- 5 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 src/common/utils/common-types.ts diff --git a/src/common/utils/common-types.ts b/src/common/utils/common-types.ts new file mode 100644 index 0000000000..d35e761136 --- /dev/null +++ b/src/common/utils/common-types.ts @@ -0,0 +1 @@ +export type Disposer = () => void; diff --git a/src/common/utils/index.ts b/src/common/utils/index.ts index 2b8147fad9..4b2feb600e 100644 --- a/src/common/utils/index.ts +++ b/src/common/utils/index.ts @@ -19,3 +19,4 @@ export * from "./downloadFile"; export * from "./escapeRegExp"; export * from "./tar"; export * from "./delay"; +export * from "./common-types"; diff --git a/src/renderer/api/kube-watch-api.ts b/src/renderer/api/kube-watch-api.ts index d5f0d79f26..0390f5389f 100644 --- a/src/renderer/api/kube-watch-api.ts +++ b/src/renderer/api/kube-watch-api.ts @@ -78,11 +78,11 @@ export class KubeWatchApi { } }; - let subscribeP: Promise; + let subscribing: Promise = Promise.resolve(); if (preloading) { if (waitUntilLoaded) { - subscribeP = preloading.loading + subscribing = preloading.loading .then(() => subscribe(ac.signal)) .catch(error => { this.log({ @@ -91,7 +91,7 @@ export class KubeWatchApi { }); }); } else { - subscribeP = subscribe(ac.signal); + subscribing = subscribe(ac.signal); } // reload stores only for context namespaces change @@ -100,14 +100,14 @@ export class KubeWatchApi { preloading.cancelLoading(); } ac.abort(); - subscribeP.then(() => { + subscribing.then(() => { unsubscribeList.forEach(unsubscribe => unsubscribe()); unsubscribeList.length = 0; ac = new AbortController(); preloading = load(namespaces); preloading.loading - .then(() => subscribeP = subscribe(ac.signal)); + .then(() => subscribing = subscribe(ac.signal)); }); }, { equals: comparer.shallow, @@ -124,7 +124,7 @@ export class KubeWatchApi { preloading.cancelLoading(); } ac.abort(); - subscribeP.then(() => { + subscribing.then(() => { unsubscribeList.forEach(unsubscribe => unsubscribe()); unsubscribeList.length = 0; }); diff --git a/src/renderer/components/+namespaces/namespace.store.ts b/src/renderer/components/+namespaces/namespace.store.ts index eaa90a4861..d7b245e414 100644 --- a/src/renderer/components/+namespaces/namespace.store.ts +++ b/src/renderer/components/+namespaces/namespace.store.ts @@ -65,11 +65,7 @@ export class NamespaceStore extends KubeObjectStore { } private autoLoadAllowedNamespaces(): IReactionDisposer { - return reaction(() => this.allowedNamespaces, namespaces => { - console.log("autoLoadAllowedNamespaces", namespaces); - - return this.loadAll({ namespaces }); - }, { + return reaction(() => this.allowedNamespaces, namespaces => this.loadAll({ namespaces }), { fireImmediately: true, equals: comparer.shallow, }); diff --git a/src/renderer/utils/index.ts b/src/renderer/utils/index.ts index 004b3b6759..517fd8f359 100755 --- a/src/renderer/utils/index.ts +++ b/src/renderer/utils/index.ts @@ -2,8 +2,6 @@ export const isElectron = !!navigator.userAgent.match(/Electron/); -export type Disposer = () => void; - export * from "../../common/utils"; export * from "./cssVar";