mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-04 18:35:17 +02:00
fix local search
This commit is contained in:
parent
07596782ab
commit
4280511372
2 changed files with 22 additions and 13 deletions
|
@ -15,6 +15,7 @@ const AppGrid = (props: ComponentProps): JSX.Element => {
|
||||||
let apps: JSX.Element;
|
let apps: JSX.Element;
|
||||||
|
|
||||||
if (props.categories.length > 0) {
|
if (props.categories.length > 0) {
|
||||||
|
if (props.apps.length > 0) {
|
||||||
apps = (
|
apps = (
|
||||||
<div className={classes.AppGrid}>
|
<div className={classes.AppGrid}>
|
||||||
{props.categories.map((category: Category): JSX.Element => {
|
{props.categories.map((category: Category): JSX.Element => {
|
||||||
|
@ -23,7 +24,6 @@ const AppGrid = (props: ComponentProps): JSX.Element => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
if (props.totalCategories) {
|
|
||||||
if (props.searching) {
|
if (props.searching) {
|
||||||
apps = (
|
apps = (
|
||||||
<p className={classes.AppsMessage}>
|
<p className={classes.AppsMessage}>
|
||||||
|
@ -33,11 +33,20 @@ const AppGrid = (props: ComponentProps): JSX.Element => {
|
||||||
} else {
|
} else {
|
||||||
apps = (
|
apps = (
|
||||||
<p className={classes.AppsMessage}>
|
<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
|
<Link to="/applications">/applications</Link> menu
|
||||||
</p>
|
</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 {
|
} else {
|
||||||
apps = (
|
apps = (
|
||||||
<p className={classes.AppsMessage}>
|
<p className={classes.AppsMessage}>
|
||||||
|
|
|
@ -101,14 +101,14 @@ const Home = (props: ComponentProps): JSX.Element => {
|
||||||
const searchInCategories = (query: string, categoriesToSearch: Category[]): Category[] => {
|
const searchInCategories = (query: string, categoriesToSearch: Category[]): Category[] => {
|
||||||
const category: Category = {
|
const category: Category = {
|
||||||
name: "Search Results",
|
name: "Search Results",
|
||||||
type: categoriesToSearch[0].type,
|
type: categoriesToSearch[0]?.type,
|
||||||
isPinned: true,
|
isPinned: true,
|
||||||
apps: categoriesToSearch
|
apps: categoriesToSearch
|
||||||
.map((c: Category) => c.apps)
|
.map((c: Category) => c.id >= 0 ? c.apps : apps.filter((app: App) => app.categoryId === c.id))
|
||||||
.flat()
|
.flat()
|
||||||
.filter((app: App) => new RegExp(query, 'i').test(app.name)),
|
.filter((app: App) => new RegExp(query, 'i').test(app.name)),
|
||||||
bookmarks: categoriesToSearch
|
bookmarks: categoriesToSearch
|
||||||
.map((c: Category) => c.bookmarks)
|
.map((c: Category) => c.id >= 0 ? c.bookmarks : bookmarks.filter((bookmark: Bookmark) => bookmark.categoryId === c.id))
|
||||||
.flat()
|
.flat()
|
||||||
.filter((bookmark: Bookmark) => new RegExp(query, 'i').test(bookmark.name)),
|
.filter((bookmark: Bookmark) => new RegExp(query, 'i').test(bookmark.name)),
|
||||||
id: 0,
|
id: 0,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue