Skip to content

Commit

Permalink
Merge pull request #2271 from voxel51/sidebar-reset
Browse files Browse the repository at this point in the history
Sidebar resets
  • Loading branch information
brimoor authored Nov 9, 2022
2 parents dd201fc + d789f5c commit 88737bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
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

0 comments on commit 88737bc

Please sign in to comment.