#182 - Support default sort option

This commit is contained in:
Elio Struyf
2021-11-21 17:56:49 +01:00
parent 1f64e59917
commit 816a2fefe7
6 changed files with 35 additions and 4 deletions
@@ -42,7 +42,7 @@ export const Sorting: React.FunctionComponent<ISortingProps> = ({disableCustomSo
allOptions = [...allOptions, ...settings.customSorting.map((s) => ({
title: s.title || s.name,
name: s.name,
id: `${s.name}-${s.order}`,
id: s.id || `${s.name}-${s.order}`,
order: s.order,
type: s.type
}))];
@@ -55,6 +55,14 @@ export const Sorting: React.FunctionComponent<ISortingProps> = ({disableCustomSo
} else if (view === ViewType.Media) {
crntSortingOption = settings?.dashboardState?.media?.sorting || null;
}
if (crntSortingOption === null) {
if (view === ViewType.Contents && settings?.dashboardState.contents.defaultSorting) {
crntSortingOption = allOptions.find(f => f.id === settings?.dashboardState.contents.defaultSorting) || null;
} else if (view === ViewType.Media && settings?.dashboardState.contents.defaultSorting) {
crntSortingOption = allOptions.find(f => f.id === settings?.dashboardState.contents.defaultSorting) || null;
}
}
}
let crntSort = allOptions.find(x => x.id === crntSortingOption?.id) || sortOptions[0];