mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
fix: wait for contextReady in NamespaceStore
Signed-off-by: Roman <ixrock@gmail.com>
This commit is contained in:
parent
77e3a7fb83
commit
36d54c64fc
@ -26,6 +26,7 @@ export interface IKubeWatchMessage<T extends KubeObject = any> {
|
||||
}
|
||||
|
||||
export interface IKubeWatchSubscribeStoreOptions {
|
||||
namespaces?: string[]; // todo: support custom namespaces to subscribe
|
||||
preload?: boolean; // preload store items, default: true
|
||||
waitUntilLoaded?: boolean; // subscribe only after loading all stores, default: true
|
||||
loadOnce?: boolean; // check store.isLoaded to skip loading if done already, default: false
|
||||
@ -133,7 +134,9 @@ export class KubeWatchApi {
|
||||
preloading.push(limitRequests(async () => {
|
||||
if (store.isLoaded && opts.loadOnce) return; // skip
|
||||
|
||||
return store.loadAll({ namespaces: opts.namespaces });
|
||||
return store.loadAll({
|
||||
namespaces: opts.namespaces ?? this.context?.contextNamespaces,
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ export class NamespaceStore extends KubeObjectStore<Namespace> {
|
||||
}
|
||||
|
||||
private async init() {
|
||||
if (!this.context) return; // skip for non-cluster context window
|
||||
await this.contextReady;
|
||||
|
||||
this.setContext(this.initialNamespaces);
|
||||
this.autoLoadAllowedNamespaces();
|
||||
|
||||
@ -138,7 +138,7 @@ export class ItemListLayout extends React.Component<ItemListLayoutProps> {
|
||||
const { store, dependentStores } = this.props;
|
||||
const stores = Array.from(new Set([store, ...dependentStores]));
|
||||
|
||||
// loads context namespaces by default (see also: `<NamespaceSelectFilter/>`)
|
||||
// load context namespaces by default (see also: `<NamespaceSelectFilter/>`)
|
||||
stores.forEach(store => store.loadAll(namespaceStore.contextNamespaces));
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user