Skip to content

Commit

Permalink
Clear extended selection for dataset changes (#5308)
Browse files Browse the repository at this point in the history
* clear extended selection for dataset changes

* fix default
  • Loading branch information
benjaminpkane authored Dec 20, 2024
1 parent e5771c6 commit 41bfd4d
Showing 1 changed file with 44 additions and 8 deletions.
52 changes: 44 additions & 8 deletions app/packages/state/src/recoil/atoms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,50 @@ export const similaritySorting = atom<boolean>({
default: false,
});

export const extendedSelection = atom<{ selection: string[]; scope?: string }>({
key: "extendedSelection",
default: { selection: null },
});
export const extendedSelectionOverrideStage = atom<any>({
key: "extendedSelectionOverrideStage",
default: null,
});
export const extendedSelection = (() => {
let current = { selection: null };
return graphQLSyncFragmentAtom<
datasetFragment$key,
{ selection: string[]; scope?: string }
>(
{
fragments: [datasetFragment],
keys: ["dataset"],
default: { selection: null },
read: (data, previous) => {
if (previous && data.id !== previous?.id) {
current = { selection: null };
}

return current;
},
},
{
key: "extendedSelection",
}
);
})();

export const extendedSelectionOverrideStage = (() => {
let current = null;
return graphQLSyncFragmentAtom<datasetFragment$key, any>(
{
fragments: [datasetFragment],
keys: ["dataset"],
default: null,
read: (data, previous) => {
if (previous && data.id !== previous?.id) {
current = null;
}

return current;
},
},
{
key: "extendedSelectionOverrideStage",
}
);
})();

export const similarityParameters = (() => {
let update = false;
Expand Down

0 comments on commit 41bfd4d

Please sign in to comment.