mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-05 10:55: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];
|
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 (
|
return (
|
||||||
<Container>
|
<Container>
|
||||||
{searchConfig('hideSearch', 0) !== 1 ? (
|
{searchConfig('hideSearch', 0) !== 1 ? (
|
||||||
|
@ -152,7 +160,7 @@ const Home = (props: ComponentProps): JSX.Element => {
|
||||||
<AppGrid
|
<AppGrid
|
||||||
categories={
|
categories={
|
||||||
!localSearch
|
!localSearch
|
||||||
? appCategories.filter((category: Category) => category.isPinned && category.apps?.length > 0)
|
? appCategories.filter((category: Category) => category.isPinned && categoryContainsItems(category, apps))
|
||||||
: searchInCategories(localSearch, appCategories)
|
: searchInCategories(localSearch, appCategories)
|
||||||
}
|
}
|
||||||
apps={
|
apps={
|
||||||
|
@ -181,7 +189,7 @@ const Home = (props: ComponentProps): JSX.Element => {
|
||||||
<BookmarkGrid
|
<BookmarkGrid
|
||||||
categories={
|
categories={
|
||||||
!localSearch
|
!localSearch
|
||||||
? bookmarkCategories.filter((category: Category) => category.isPinned && category.bookmarks?.length > 0)
|
? bookmarkCategories.filter((category: Category) => category.isPinned && categoryContainsItems(category, bookmarks))
|
||||||
: searchInCategories(localSearch, bookmarkCategories)
|
: searchInCategories(localSearch, bookmarkCategories)
|
||||||
}
|
}
|
||||||
bookmarks={
|
bookmarks={
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue