mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Fix rerendering of KubeObject views every 30s (#4801)
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
105 files changed
+1442
-709
No files matched your search
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import { getInjectable, lifecycleEnum } from "@ogre-tools/injectable";
|
||||
import { asyncComputed } from "@ogre-tools/injectable-react";
|
||||
import namespaceStoreInjectable from "../+namespaces/namespace-store/namespace-store.injectable";
|
||||
import { listReleases } from "../../../common/k8s-api/endpoints/helm-releases.api";
|
||||
|
||||
const releasesInjectable = getInjectable({
|
||||
instantiate: (di) => {
|
||||
const namespaceStore = di.inject(namespaceStoreInjectable);
|
||||
|
||||
// TODO: Inject clusterContext directly instead of accessing dependency of a dependency
|
||||
const clusterContext = namespaceStore.context;
|
||||
|
||||
return asyncComputed(async () => {
|
||||
const contextNamespaces = namespaceStore.contextNamespaces || [];
|
||||
|
||||
const isLoadingAll =
|
||||
clusterContext.allNamespaces?.length > 1 &&
|
||||
clusterContext.cluster.accessibleNamespaces.length === 0 &&
|
||||
clusterContext.allNamespaces.every((namespace) =>
|
||||
contextNamespaces.includes(namespace),
|
||||
);
|
||||
|
||||
const releaseArrays = await (isLoadingAll ? listReleases() : Promise.all(
|
||||
contextNamespaces.map((namespace) =>
|
||||
listReleases(namespace),
|
||||
),
|
||||
));
|
||||
|
||||
return releaseArrays.flat();
|
||||
}, []);
|
||||
},
|
||||
|
||||
lifecycle: lifecycleEnum.singleton,
|
||||
});
|
||||
|
||||
export default releasesInjectable;
|
||||
Reference in new issue
Block a user