Skip to content

Commit 372b43d

Browse files
authored
refactor(filters): sort sections by title (#2354)
Signed-off-by: Adam Setch <adam.setch@outlook.com>
1 parent f404642 commit 372b43d

File tree

7 files changed

+813
-802
lines changed

7 files changed

+813
-802
lines changed

src/renderer/components/filters/FilterSection.tsx

Lines changed: 35 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -53,31 +53,42 @@ export const FilterSection = <T extends FilterValue>({
5353
direction={layout}
5454
gap={layout === 'horizontal' ? 'normal' : 'condensed'}
5555
>
56-
{(Object.keys(filter.FILTER_TYPES) as T[]).map((type) => {
57-
const typeDetails = filter.getTypeDetails(type);
58-
const typeTitle = typeDetails.title;
59-
const typeDescription = typeDetails.description;
60-
const isChecked = filter.isFilterSet(settings, type);
61-
const count = filter.getFilterCount(notifications, type);
56+
{(Object.keys(filter.FILTER_TYPES) as T[])
57+
.sort((a, b) =>
58+
filter
59+
.getTypeDetails(a)
60+
.title.toLocaleLowerCase()
61+
.localeCompare(
62+
filter.getTypeDetails(b).title.toLocaleLowerCase(),
63+
),
64+
)
65+
.map((type) => {
66+
const typeDetails = filter.getTypeDetails(type);
67+
const typeTitle = typeDetails.title;
68+
const typeDescription = typeDetails.description;
69+
const isChecked = filter.isFilterSet(settings, type);
70+
const count = filter.getFilterCount(notifications, type);
6271

63-
return (
64-
<Checkbox
65-
checked={isChecked}
66-
counter={count}
67-
disabled={
68-
filter.requiresDetailsNotifications &&
69-
!settings.detailedNotifications
70-
}
71-
key={type as string}
72-
label={typeTitle}
73-
name={typeTitle}
74-
onChange={(evt) =>
75-
updateFilter(filterSetting, type, evt.target.checked)
76-
}
77-
tooltip={typeDescription ? <Text>{typeDescription}</Text> : null}
78-
/>
79-
);
80-
})}
72+
return (
73+
<Checkbox
74+
checked={isChecked}
75+
counter={count}
76+
disabled={
77+
filter.requiresDetailsNotifications &&
78+
!settings.detailedNotifications
79+
}
80+
key={type as string}
81+
label={typeTitle}
82+
name={typeTitle}
83+
onChange={(evt) =>
84+
updateFilter(filterSetting, type, evt.target.checked)
85+
}
86+
tooltip={
87+
typeDescription ? <Text>{typeDescription}</Text> : null
88+
}
89+
/>
90+
);
91+
})}
8192
</Stack>
8293
</fieldset>
8394
);

0 commit comments

Comments
 (0)