Skip to content

Commit

Permalink
fix: theme sorting in quick settings menu (#882)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanharwara authored Feb 18, 2022
1 parent d27916f commit a47556b
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const toggleFocusMode = (enabled: boolean) => {
}
};

export const sortThemes = (a: SNTheme, b: SNTheme) => {
const aIsLayerable = a.isLayerable();
const bIsLayerable = b.isLayerable();
export const sortThemes = (a: ThemeItem, b: ThemeItem) => {
const aIsLayerable = a.component?.isLayerable();
const bIsLayerable = b.component?.isLayerable();

if (aIsLayerable && !bIsLayerable) {
return 1;
Expand Down Expand Up @@ -105,15 +105,13 @@ export const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
const reloadThemes = useCallback(() => {
const themes = (
application.getDisplayableItems(ContentType.Theme) as SNTheme[]
)
.sort(sortThemes)
.map((item) => {
return {
name: item.name,
identifier: item.identifier,
component: item,
};
}) as ThemeItem[];
).map((item) => {
return {
name: item.name,
identifier: item.identifier,
component: item,
};
}) as ThemeItem[];

GetFeatures()
.filter(
Expand All @@ -132,7 +130,7 @@ export const QuickSettingsMenu: FunctionComponent<MenuProps> = observer(
}
});

setThemes(themes);
setThemes(themes.sort(sortThemes));

setDefaultThemeOn(
!themes
Expand Down

0 comments on commit a47556b

Please sign in to comment.