Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Jul 30, 2024
1 parent 6ca159e commit 07455f8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 32 deletions.
17 changes: 6 additions & 11 deletions frontend/src/framework/GlobalAtoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,13 @@ export const EnsembleRealizationFilterFunctionAtom = atom<EnsembleRealizationFil
realizationFilterSet.getRealizationFilterForEnsembleIdent(ensembleIdent).getFilteredRealizations();
});

function areRealizationFilterSetsEqual(a: RealizationFilterSet | null, b: RealizationFilterSet | null): boolean {
if (a === null && b === null) {
return true;
}

if (a === null || b === null) {
return false;
}

return a.isEqual(b);
function areRealizationFilterSetsEqual(
a: { filterSet: RealizationFilterSet } | null,
b: { filterSet: RealizationFilterSet } | null
): boolean {
return a === b;
}

export const RealizationFilterSetAtom = atomWithCompare<{
filterSet: RealizationFilterSet;
} | null>(null, (a, b) => areRealizationFilterSetsEqual(a?.filterSet ?? null, b?.filterSet ?? null));
} | null>(null, (a, b) => areRealizationFilterSetsEqual(a, b));
4 changes: 3 additions & 1 deletion frontend/src/framework/internal/WorkbenchSessionPrivate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ export class WorkbenchSessionPrivate extends WorkbenchSession {
}

notifyAboutEnsembleRealizationFilterChange(): void {
this._atomStoreMaster.setAtomValue(RealizationFilterSetAtom, { filterSet: this._realizationFilterSet });
this._atomStoreMaster.setAtomValue(RealizationFilterSetAtom, {
filterSet: this._realizationFilterSet,
});
this.notifySubscribers(WorkbenchSessionEvent.RealizationFilterSetChanged);
}
}
21 changes: 1 addition & 20 deletions frontend/src/modules/Intersection/settings/atoms/derivedAtoms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EnsembleIdent } from "@framework/EnsembleIdent";
import { EnsembleSet } from "@framework/EnsembleSet";
import { EnsembleRealizationFilterFunctionAtom, EnsembleSetAtom } from "@framework/GlobalAtoms";
import { EnsembleSetAtom } from "@framework/GlobalAtoms";
import { IntersectionPolylinesAtom } from "@framework/userCreatedItems/IntersectionPolylines";
import { LayerManager } from "@modules/Intersection/utils/layers/LayerManager";

Expand Down Expand Up @@ -37,25 +37,6 @@ export const selectedFieldIdentifierAtom = atom((get) => {
return selectedFieldIdentifier;
});

export const availableRealizationsAtom = atom((get) => {
const ensembleSet = get(EnsembleSetAtom);
const selectedEnsembleIdent = get(selectedEnsembleIdentAtom);

if (selectedEnsembleIdent === null) {
return [];
}

let ensembleRealizationFilterFunction = get(EnsembleRealizationFilterFunctionAtom);

if (ensembleRealizationFilterFunction === null) {
ensembleRealizationFilterFunction = (ensembleIdent: EnsembleIdent) => {
return ensembleSet.findEnsemble(ensembleIdent)?.getRealizations() ?? [];
};
}

return ensembleRealizationFilterFunction(selectedEnsembleIdent);
});

export const availableUserCreatedIntersectionPolylinesAtom = atom((get) => {
const intersectionPolylines = get(IntersectionPolylinesAtom);
return intersectionPolylines;
Expand Down

0 comments on commit 07455f8

Please sign in to comment.