Merge pull request #2547 from omnivore-app/feat/web-remember-menu-state

Persist the viewAll states for left menu items
This commit is contained in:
Jackson Harper 2023-07-26 15:13:50 +08:00 committed by GitHub
commit 2fa4288edb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,6 +10,7 @@ import { Label } from '../../../lib/networking/fragments/labelFragment'
import { theme } from '../../tokens/stitches.config'
import { useRegisterActions } from 'kbar'
import { LogoBox } from '../../elements/LogoBox'
import { usePersistedState } from '../../../lib/hooks/usePersistedState'
export const LIBRARY_LEFT_MENU_WIDTH = '233px'
@ -146,7 +147,10 @@ function SavedSearches(props: LibraryFilterMenuProps): JSX.Element {
function Subscriptions(props: LibraryFilterMenuProps): JSX.Element {
const { subscriptions } = useGetSubscriptionsQuery()
const [viewAll, setViewAll] = useState(false)
const [viewAll, setViewAll] = usePersistedState<boolean>({
key: `--subscriptions-view-all`,
initialValue: false,
})
useRegisterActions(
(subscriptions ?? []).map((subscription, idx) => {
@ -194,7 +198,10 @@ function Subscriptions(props: LibraryFilterMenuProps): JSX.Element {
function Labels(props: LibraryFilterMenuProps): JSX.Element {
const { labels } = useGetLabelsQuery()
const [viewAll, setViewAll] = useState(false)
const [viewAll, setViewAll] = usePersistedState<boolean>({
key: `--labels-view-all`,
initialValue: false,
})
return (
<MenuPanel