Sort labels in the left menu alphabetically

This commit is contained in:
Jackson Harper 2023-08-03 12:24:09 +08:00
parent ec1b14796a
commit ebbc14f841

View file

@ -203,6 +203,12 @@ function Labels(props: LibraryFilterMenuProps): JSX.Element {
initialValue: false,
})
const sortedLabels = useMemo(() => {
return labels.sort((left: Label, right: Label) =>
left.name.localeCompare(right.name)
)
}, [labels])
return (
<MenuPanel
title="Labels"
@ -212,7 +218,7 @@ function Labels(props: LibraryFilterMenuProps): JSX.Element {
window.location.href = '/settings/labels'
}}
>
{labels.slice(0, viewAll ? undefined : 4).map((item) => {
{sortedLabels.slice(0, viewAll ? undefined : 4).map((item) => {
return <LabelButton key={item.id} label={item} {...props} />
})}
<ViewAllButton state={viewAll} setState={setViewAll} />