web: allow sorting by title everywhere

This commit is contained in:
Abdullah Atta
2024-02-17 11:24:47 +05:00
parent 13b821e061
commit f5de8caa0d

View File

@@ -59,7 +59,6 @@ type GroupingMenuOptions = {
parentKey: keyof GroupOptions;
groupingKey: GroupingKey;
refresh: () => void;
isUngrouped: boolean;
};
const groupByMenu: (options: GroupingMenuOptions) => MenuItem | null = (
@@ -130,8 +129,7 @@ const sortByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({
{
key: "dateCreated",
title: "Date created",
isHidden:
options.groupingKey === "trash" || options.groupingKey === "tags"
isHidden: options.groupingKey === "trash"
},
{
key: "dateEdited",
@@ -156,12 +154,7 @@ const sortByMenu: (options: GroupingMenuOptions) => MenuItem = (options) => ({
},
{
key: "title",
title: "Title",
isHidden:
!options.isUngrouped &&
options.parentKey === "sortBy" &&
options.groupOptions.groupBy !== "abc" &&
options.groupOptions.groupBy !== "none"
title: "Title"
}
])
}
@@ -174,7 +167,6 @@ export function showSortMenu(groupingKey: GroupingKey, refresh: () => void) {
const menuOptions: Omit<GroupingMenuOptions, "parentKey"> = {
groupingKey,
groupOptions,
isUngrouped: true,
refresh
};
@@ -199,11 +191,10 @@ async function changeGroupOptions(
(groupOptions as any)[options.parentKey] = item.key;
if (options.parentKey === "groupBy") {
if (item.key === "abc") groupOptions.sortBy = "title";
else
groupOptions.sortBy =
options.groupingKey === "tags" || options.groupingKey === "trash"
? "dateModified"
: "dateEdited";
: groupOptions.sortBy;
}
await db.settings.setGroupOptions(options.groupingKey, groupOptions);
options.refresh();
@@ -366,7 +357,6 @@ function GroupHeader(props: GroupHeaderProps) {
const menuOptions: Omit<GroupingMenuOptions, "parentKey"> = {
groupingKey,
groupOptions,
isUngrouped: false,
refresh
};
const groupBy = groupByMenu({