From a47556b8406d2956c839cc4882b0a44d69d3e66c Mon Sep 17 00:00:00 2001 From: Aman Harwara Date: Fri, 18 Feb 2022 19:12:11 +0530 Subject: [PATCH] fix: theme sorting in quick settings menu (#882) --- .../QuickSettingsMenu/QuickSettingsMenu.tsx | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/app/assets/javascripts/components/QuickSettingsMenu/QuickSettingsMenu.tsx b/app/assets/javascripts/components/QuickSettingsMenu/QuickSettingsMenu.tsx index 7fea580bb59..957b77d6b1a 100644 --- a/app/assets/javascripts/components/QuickSettingsMenu/QuickSettingsMenu.tsx +++ b/app/assets/javascripts/components/QuickSettingsMenu/QuickSettingsMenu.tsx @@ -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; @@ -105,15 +105,13 @@ export const QuickSettingsMenu: FunctionComponent = 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( @@ -132,7 +130,7 @@ export const QuickSettingsMenu: FunctionComponent = observer( } }); - setThemes(themes); + setThemes(themes.sort(sortThemes)); setDefaultThemeOn( !themes