diff --git a/src/renderer/components/+namespaces/namespace-select-filter.tsx b/src/renderer/components/+namespaces/namespace-select-filter.tsx index 453849e534..85a6299b17 100644 --- a/src/renderer/components/+namespaces/namespace-select-filter.tsx +++ b/src/renderer/components/+namespaces/namespace-select-filter.tsx @@ -56,7 +56,7 @@ export class NamespaceSelectFilter extends React.Component { if (namespace) { namespaceStore.toggleContext(namespace); } else { - namespaceStore.resetContext(); // "All namespaces" clicked, empty list considered as "all" + namespaceStore.toggleAll(false); // "All namespaces" clicked } } diff --git a/src/renderer/components/+namespaces/namespace-select.tsx b/src/renderer/components/+namespaces/namespace-select.tsx index 207a274d2c..775cace4d3 100644 --- a/src/renderer/components/+namespaces/namespace-select.tsx +++ b/src/renderer/components/+namespaces/namespace-select.tsx @@ -29,6 +29,7 @@ export class NamespaceSelect extends React.Component { disposeOnUnmount(this, [ kubeWatchApi.subscribeStores([namespaceStore], { preload: true, + loadOnce: true, // skip reloading namespaces on every render / page visit }) ]); } diff --git a/src/renderer/components/+namespaces/namespace.store.ts b/src/renderer/components/+namespaces/namespace.store.ts index 1f928fe2f3..ad271d1302 100644 --- a/src/renderer/components/+namespaces/namespace.store.ts +++ b/src/renderer/components/+namespaces/namespace.store.ts @@ -5,7 +5,7 @@ import { Namespace, namespacesApi } from "../../api/endpoints/namespaces.api"; import { createPageParam } from "../../navigation"; import { apiManager } from "../../api/api-manager"; -const storage = createStorage("context_namespaces", []); +const storage = createStorage("context_namespaces"); export const namespaceUrlParam = createPageParam({ name: "namespaces", @@ -74,11 +74,11 @@ export class NamespaceStore extends KubeObjectStore { @computed private get initialNamespaces(): string[] { const namespaces = new Set(this.allowedNamespaces); - const prevSelected = storage.get().filter(namespace => namespaces.has(namespace)); + const prevSelectedNamespaces = storage.get(); - // return previously saved namespaces from local-storage - if (prevSelected.length > 0) { - return prevSelected; + // return previously saved namespaces from local-storage (if any) + if (prevSelectedNamespaces) { + return prevSelectedNamespaces.filter(namespace => namespaces.has(namespace)); } // otherwise select "default" or first allowed namespace @@ -166,7 +166,7 @@ export class NamespaceStore extends KubeObjectStore { if (showAll) { this.setContext(this.allowedNamespaces); } else { - this.contextNs.clear(); + this.resetContext(); // empty context considered as "All namespaces" } } else { this.toggleAll(!this.hasAllContexts);