Fix race condition in refreshViews (#4094)

This commit is contained in:
Sebastian Malton authored and GitHub committed 2021-11-10 12:07:55 -05:00
1 parent c8fbb35967
commit de4c7e4cff
6 files changed
+131 -84

No files matched your search

+18 -2
View File
@@ -41,6 +41,8 @@ export class ClusterManager extends Singleton {
private store = ClusterStore.getInstance();
deleting = observable.set<ClusterId>();
@observable visibleCluster: ClusterId | undefined = undefined;
constructor() {
super();
makeObservable(this);
@@ -61,8 +63,22 @@ export class ClusterManager extends Singleton {
{ fireImmediately: false },
);
reaction(() => catalogEntityRegistry.getItemsForApiKind<KubernetesCluster>("entity.k8slens.dev/v1alpha1", "KubernetesCluster"), (entities) => {
this.syncClustersFromCatalog(entities);
reaction(
() => catalogEntityRegistry.getItemsByEntityClass(KubernetesCluster),
entities => this.syncClustersFromCatalog(entities),
);
reaction(() => [
catalogEntityRegistry.getItemsByEntityClass(KubernetesCluster),
this.visibleCluster,
] as const, ([entities, visibleCluster]) => {
for (const entity of entities) {
if (entity.getId() === visibleCluster) {
entity.status.active = true;
} else {
entity.status.active = false;
}
}
});
observe(this.deleting, change => {