Persist the viewAll states for left menu items

This commit is contained in:
Jackson Harper 2023-07-26 12:41:20 +08:00
parent 3eb3406d41
commit 49969b6c42

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 | undefined>({
key: `--labels-view-all`,
initialValue: false,
})
return (
<MenuPanel