Use a separate section for search so we can better control the folder

This commit is contained in:
Jackson Harper
2024-08-13 23:38:18 +08:00
parent cca1cbfff4
commit 588f7d0fdc
4 changed files with 29 additions and 16 deletions

View File

@ -131,7 +131,7 @@ const userDefaultShortcuts = async (userId: string): Promise<Shortcut[]> => {
id: label.id,
type: 'label',
name: label.name,
section: 'library',
section: 'search',
label: label,
filter: `in:all label:"${label.name}"`,
}
@ -166,7 +166,7 @@ const userDefaultShortcuts = async (userId: string): Promise<Shortcut[]> => {
id: search.id,
type: 'search',
name: search.name,
section: 'library',
section: 'seach',
filter: search.filter,
}
}),

View File

@ -69,6 +69,10 @@ const moduleExports = {
source: '/subscriptions',
destination: '/l/subscriptions',
})
rewrites.push({
source: '/search',
destination: '/l/search',
})
rewrites.push({
source: '/archive',
destination: '/l/archive',

View File

@ -84,6 +84,17 @@ export default function Home(): JSX.Element {
showNavigationMenu={showNavigationMenu}
/>
)
case 'search':
return (
<LibraryContainer
folder={undefined}
filterFunc={(item) => {
console.log('item: ', item)
return true
}}
showNavigationMenu={showNavigationMenu}
/>
)
case 'archive':
return (
<LibraryContainer

View File

@ -40,6 +40,7 @@ import { useGetLabels } from '../../lib/networking/labels/useLabels'
import { useGetSavedSearches } from '../../lib/networking/savedsearches/useSavedSearches'
import {
Shortcut,
ShortcutType,
useGetShortcuts,
useResetShortcuts,
useSetShortcuts,
@ -220,25 +221,22 @@ const SavedSearches = (props: ListProps) => {
<SwitchBox
checked={isChecked(search.id)}
setChecked={(checked) => {
const item = {
id: search.id,
type: 'search' as ShortcutType,
name: search.name,
section: 'search',
filter: search.filter,
}
if (checked) {
props.dispatchList({
type: 'ADD_ITEM',
item: {
id: search.id,
type: 'search',
name: search.name,
section: 'library',
filter: search.filter,
},
item,
})
} else {
props.dispatchList({
type: 'REMOVE_ITEM',
item: {
type: 'search',
section: 'library',
...search,
},
item,
})
}
}}
@ -383,9 +381,9 @@ const Labels = (props: ListProps) => {
id: label.id,
type: 'label',
label: label,
section: 'library',
section: 'search',
name: label.name,
filter: `label:\"${escapeQuotes(label.name)}\"`,
filter: `in:all label:\"${escapeQuotes(label.name)}\"`,
}
if (checked) {
props.dispatchList({