Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar resets #2271

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions app/packages/state/src/hooks/useStateUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,19 @@ const useStateUpdate = () => {
dataset.evaluations = Object.values(dataset.evaluations || {});
dataset.sampleFields = collapseFields(dataset.sampleFields);
dataset.frameFields = collapseFields(dataset.frameFields);
const previousDataset = get(datasetAtom);

const currentSidebar = get(sidebarGroupsDefinition(false));
const groups = resolveGroups(dataset, currentSidebar);

if (JSON.stringify(groups) !== JSON.stringify(currentSidebar)) {
set(sidebarGroupsDefinition(false), groups);
set(aggregationsTick, get(aggregationsTick) + 1);
}
let groups = resolveGroups(dataset, currentSidebar);

const previousDataset = get(datasetAtom);
if (
!previousDataset ||
previousDataset.id !== dataset.id ||
dataset.groupSlice !== previousDataset.groupSlice
) {
if (dataset?.name !== previousDataset?.name) {
reset(sidebarMode(false));
groups = resolveGroups(dataset);
}
reset(_activeFields({ modal: false }));
let slice = dataset.groupSlice;
Expand All @@ -141,6 +137,9 @@ const useStateUpdate = () => {
reset(filters);
}

if (JSON.stringify(groups) !== JSON.stringify(currentSidebar)) {
set(sidebarGroupsDefinition(false), groups);
}
set(datasetAtom, dataset);
}

Expand Down
11 changes: 6 additions & 5 deletions app/packages/state/src/recoil/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,12 @@ export const resolveGroups = (
): State.SidebarGroup[] => {
let groups = dataset?.appConfig?.sidebarGroups;

const expanded = current.reduce((map, { name, expanded }) => {
map[name] = expanded;
return map;
}, {});

const expanded = current
? current.reduce((map, { name, expanded }) => {
map[name] = expanded;
return map;
}, {})
: {};
if (!groups) {
groups = dataset.frameFields.length
? DEFAULT_VIDEO_GROUPS
Expand Down