Skip to content

Commit

Permalink
resolve review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Malton <sebastian@malton.name>
  • Loading branch information
Nokel81 committed Feb 11, 2021
1 parent aed51c1 commit 80352f5
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/common/utils/common-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type Disposer = () => void;
1 change: 1 addition & 0 deletions src/common/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export * from "./downloadFile";
export * from "./escapeRegExp";
export * from "./tar";
export * from "./delay";
export * from "./common-types";
12 changes: 6 additions & 6 deletions src/renderer/api/kube-watch-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ export class KubeWatchApi {
}
};

let subscribeP: Promise<void>;
let subscribing: Promise<void> = Promise.resolve();

if (preloading) {
if (waitUntilLoaded) {
subscribeP = preloading.loading
subscribing = preloading.loading
.then(() => subscribe(ac.signal))
.catch(error => {
this.log({
Expand All @@ -91,7 +91,7 @@ export class KubeWatchApi {
});
});
} else {
subscribeP = subscribe(ac.signal);
subscribing = subscribe(ac.signal);
}

// reload stores only for context namespaces change
Expand All @@ -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,
Expand All @@ -124,7 +124,7 @@ export class KubeWatchApi {
preloading.cancelLoading();
}
ac.abort();
subscribeP.then(() => {
subscribing.then(() => {
unsubscribeList.forEach(unsubscribe => unsubscribe());
unsubscribeList.length = 0;
});
Expand Down
6 changes: 1 addition & 5 deletions src/renderer/components/+namespaces/namespace.store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
}

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,
});
Expand Down
2 changes: 0 additions & 2 deletions src/renderer/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

export const isElectron = !!navigator.userAgent.match(/Electron/);

export type Disposer = () => void;

export * from "../../common/utils";

export * from "./cssVar";
Expand Down

0 comments on commit 80352f5

Please sign in to comment.