mirror of
https://github.com/pawelmalak/flame.git
synced 2025-08-01 17:05:18 +02:00
fix bookmarks display
fix apps search search in urls in addition to names
This commit is contained in:
parent
e7cd4d7705
commit
423670adb5
3 changed files with 24 additions and 14 deletions
|
@ -26,15 +26,19 @@ export const AppGrid = (props: Props): JSX.Element => {
|
||||||
config: { config }
|
config: { config }
|
||||||
} = useSelector((state: State) => state);
|
} = useSelector((state: State) => state);
|
||||||
|
|
||||||
|
const shouldBeShown = (category: Category) => {
|
||||||
|
return !config.hideEmptyCategories || category.apps.length > 0 || !fromHomepage
|
||||||
|
}
|
||||||
|
|
||||||
let apps: JSX.Element;
|
let apps: JSX.Element;
|
||||||
|
|
||||||
if (categories.length) {
|
if (categories.length && categories.some(shouldBeShown)) {
|
||||||
if (searching && !categories[0].apps.length) {
|
if (searching && !categories[0].apps.length) {
|
||||||
apps = <Message>No apps match your search criteria</Message>;
|
apps = <Message>No apps match your search criteria</Message>;
|
||||||
} else {
|
} else {
|
||||||
apps = (
|
apps = (
|
||||||
<div className={classes.AppGrid}>
|
<div className={classes.AppGrid}>
|
||||||
{categories.filter((category : Category) => !config.hideEmptyCategories || category.apps.length > 0).map(
|
{categories.filter(shouldBeShown).map(
|
||||||
(category: Category): JSX.Element => (
|
(category: Category): JSX.Element => (
|
||||||
<AppCard
|
<AppCard
|
||||||
category={category}
|
category={category}
|
||||||
|
@ -47,7 +51,7 @@ export const AppGrid = (props: Props): JSX.Element => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (totalCategories) {
|
if (totalCategories && !config.hideEmptyCategories) {
|
||||||
apps = (
|
apps = (
|
||||||
<Message>
|
<Message>
|
||||||
There are no pinned categories. You can pin them from the{' '}
|
There are no pinned categories. You can pin them from the{' '}
|
||||||
|
|
|
@ -26,15 +26,19 @@ export const BookmarkGrid = (props: Props): JSX.Element => {
|
||||||
config: { config }
|
config: { config }
|
||||||
} = useSelector((state: State) => state);
|
} = useSelector((state: State) => state);
|
||||||
|
|
||||||
|
const shouldBeShown = (category: Category) => {
|
||||||
|
return !config.hideEmptyCategories || category.bookmarks.length > 0 || !fromHomepage
|
||||||
|
}
|
||||||
|
|
||||||
let bookmarks: JSX.Element;
|
let bookmarks: JSX.Element;
|
||||||
|
|
||||||
if (categories.length) {
|
if (categories.length && categories.some(shouldBeShown)) {
|
||||||
if (searching && !categories[0].bookmarks.length) {
|
if (searching && !categories[0].bookmarks.length) {
|
||||||
bookmarks = <Message>No bookmarks match your search criteria</Message>;
|
bookmarks = <Message>No bookmarks match your search criteria</Message>;
|
||||||
} else {
|
} else {
|
||||||
bookmarks = (
|
bookmarks = (
|
||||||
<div className={classes.BookmarkGrid}>
|
<div className={classes.BookmarkGrid}>
|
||||||
{categories.filter((category : Category) => !config.hideEmptyCategories || category.apps.length > 0).map(
|
{categories.filter(shouldBeShown).map(
|
||||||
(category: Category): JSX.Element => (
|
(category: Category): JSX.Element => (
|
||||||
<BookmarkCard
|
<BookmarkCard
|
||||||
category={category}
|
category={category}
|
||||||
|
@ -47,7 +51,7 @@ export const BookmarkGrid = (props: Props): JSX.Element => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (totalCategories) {
|
if (totalCategories && !config.hideEmptyCategories) {
|
||||||
bookmarks = (
|
bookmarks = (
|
||||||
<Message>
|
<Message>
|
||||||
There are no pinned categories. You can pin them from the{' '}
|
There are no pinned categories. You can pin them from the{' '}
|
||||||
|
|
|
@ -36,7 +36,7 @@ export const Home = (): JSX.Element => {
|
||||||
null | Category[]
|
null | Category[]
|
||||||
>(null);
|
>(null);
|
||||||
|
|
||||||
// Load apps
|
// Load apps and bookmarks
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!appCategories.length && !bookmarkCategories.length) {
|
if (!appCategories.length && !bookmarkCategories.length) {
|
||||||
getCategories();
|
getCategories();
|
||||||
|
@ -59,11 +59,12 @@ export const Home = (): JSX.Element => {
|
||||||
appCategory.apps = appCategories
|
appCategory.apps = appCategories
|
||||||
.map(({ apps }) => apps)
|
.map(({ apps }) => apps)
|
||||||
.flat()
|
.flat()
|
||||||
.filter(({ name }) =>
|
.filter(({ name, url }) =>
|
||||||
new RegExp(escapeRegex(localSearch), 'i').test(name)
|
new RegExp(escapeRegex(localSearch), 'i').test(name) ||
|
||||||
|
new RegExp(escapeRegex(localSearch), 'i').test(url)
|
||||||
);
|
);
|
||||||
|
|
||||||
setBookmarkSearchResult([appCategory]);
|
setAppSearchResult([appCategory]);
|
||||||
|
|
||||||
// Search through bookmarks
|
// Search through bookmarks
|
||||||
const bookmarkCategory = { ...bookmarkCategories[0] };
|
const bookmarkCategory = { ...bookmarkCategories[0] };
|
||||||
|
@ -72,8 +73,9 @@ export const Home = (): JSX.Element => {
|
||||||
bookmarkCategory.bookmarks = bookmarkCategories
|
bookmarkCategory.bookmarks = bookmarkCategories
|
||||||
.map(({ bookmarks }) => bookmarks)
|
.map(({ bookmarks }) => bookmarks)
|
||||||
.flat()
|
.flat()
|
||||||
.filter(({ name }) =>
|
.filter(({ name, url }) =>
|
||||||
new RegExp(escapeRegex(localSearch), 'i').test(name)
|
new RegExp(escapeRegex(localSearch), 'i').test(name) ||
|
||||||
|
new RegExp(escapeRegex(localSearch), 'i').test(url)
|
||||||
);
|
);
|
||||||
|
|
||||||
setBookmarkSearchResult([bookmarkCategory]);
|
setBookmarkSearchResult([bookmarkCategory]);
|
||||||
|
@ -122,6 +124,7 @@ export const Home = (): JSX.Element => {
|
||||||
}
|
}
|
||||||
totalCategories={appCategories.length}
|
totalCategories={appCategories.length}
|
||||||
searching={!!localSearch}
|
searching={!!localSearch}
|
||||||
|
fromHomepage={true}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className={classes.HomeSpace}></div>
|
<div className={classes.HomeSpace}></div>
|
||||||
|
@ -130,8 +133,7 @@ export const Home = (): JSX.Element => {
|
||||||
<></>
|
<></>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!config.hideBookmarks &&
|
{!config.hideBookmarks && (isAuthenticated || bookmarkCategories.some((c) => c.isPinned)) ? (
|
||||||
(isAuthenticated || bookmarkCategories.some((c) => c.isPinned)) ? (
|
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<SectionHeadline title="Bookmarks" link="/bookmarks" />
|
<SectionHeadline title="Bookmarks" link="/bookmarks" />
|
||||||
{bookmarksLoading ? (
|
{bookmarksLoading ? (
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue