mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-04 18:35:17 +02:00
fix for default categories not being shown
This commit is contained in:
parent
21aabf7267
commit
07596782ab
1 changed files with 10 additions and 2 deletions
|
@ -120,6 +120,14 @@ const Home = (props: ComponentProps): JSX.Element => {
|
|||
return [category];
|
||||
};
|
||||
|
||||
const categoryContainsItems = (category: Category, allItems: App[] | Bookmark[]): boolean => {
|
||||
if (category.apps?.length > 0) return true;
|
||||
if (category.id < 0) { // Is a default category
|
||||
return allItems.findIndex((item: App | Bookmark) => item.categoryId === category.id) >= 0;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
return (
|
||||
<Container>
|
||||
{searchConfig('hideSearch', 0) !== 1 ? (
|
||||
|
@ -152,7 +160,7 @@ const Home = (props: ComponentProps): JSX.Element => {
|
|||
<AppGrid
|
||||
categories={
|
||||
!localSearch
|
||||
? appCategories.filter((category: Category) => category.isPinned && category.apps?.length > 0)
|
||||
? appCategories.filter((category: Category) => category.isPinned && categoryContainsItems(category, apps))
|
||||
: searchInCategories(localSearch, appCategories)
|
||||
}
|
||||
apps={
|
||||
|
@ -181,7 +189,7 @@ const Home = (props: ComponentProps): JSX.Element => {
|
|||
<BookmarkGrid
|
||||
categories={
|
||||
!localSearch
|
||||
? bookmarkCategories.filter((category: Category) => category.isPinned && category.bookmarks?.length > 0)
|
||||
? bookmarkCategories.filter((category: Category) => category.isPinned && categoryContainsItems(category, bookmarks))
|
||||
: searchInCategories(localSearch, bookmarkCategories)
|
||||
}
|
||||
bookmarks={
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue