1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-02 17:35:17 +02:00

fix local search

This commit is contained in:
François Darveau 2021-09-06 13:03:23 -04:00
parent 07596782ab
commit 4280511372
2 changed files with 22 additions and 13 deletions

View file

@ -15,15 +15,15 @@ const AppGrid = (props: ComponentProps): JSX.Element => {
let apps: JSX.Element;
if (props.categories.length > 0) {
apps = (
<div className={classes.AppGrid}>
{props.categories.map((category: Category): JSX.Element => {
return <AppCard key={category.id} category={category} apps={props.apps.filter((app: App) => app.categoryId === category.id)} />
})}
</div>
);
} else {
if (props.totalCategories) {
if (props.apps.length > 0) {
apps = (
<div className={classes.AppGrid}>
{props.categories.map((category: Category): JSX.Element => {
return <AppCard key={category.id} category={category} apps={props.apps.filter((app: App) => app.categoryId === category.id)} />
})}
</div>
);
} else {
if (props.searching) {
apps = (
<p className={classes.AppsMessage}>
@ -33,11 +33,20 @@ const AppGrid = (props: ComponentProps): JSX.Element => {
} else {
apps = (
<p className={classes.AppsMessage}>
There are no pinned application categories. You can pin them from the{' '}
You don't have any applications. You can add a new one from the{' '}
<Link to="/applications">/applications</Link> menu
</p>
);
}
}
} else {
if (props.totalCategories) {
apps = (
<p className={classes.AppsMessage}>
There are no pinned application categories. You can pin them from the{' '}
<Link to="/applications">/applications</Link> menu
</p>
);
} else {
apps = (
<p className={classes.AppsMessage}>

View file

@ -101,14 +101,14 @@ const Home = (props: ComponentProps): JSX.Element => {
const searchInCategories = (query: string, categoriesToSearch: Category[]): Category[] => {
const category: Category = {
name: "Search Results",
type: categoriesToSearch[0].type,
type: categoriesToSearch[0]?.type,
isPinned: true,
apps: categoriesToSearch
.map((c: Category) => c.apps)
.map((c: Category) => c.id >= 0 ? c.apps : apps.filter((app: App) => app.categoryId === c.id))
.flat()
.filter((app: App) => new RegExp(query, 'i').test(app.name)),
bookmarks: categoriesToSearch
.map((c: Category) => c.bookmarks)
.map((c: Category) => c.id >= 0 ? c.bookmarks : bookmarks.filter((bookmark: Bookmark) => bookmark.categoryId === c.id))
.flat()
.filter((bookmark: Bookmark) => new RegExp(query, 'i').test(bookmark.name)),
id: 0,