From 49969b6c42c9a9a4f445af8ea9994dbbebabbc92 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Wed, 26 Jul 2023 12:41:20 +0800 Subject: [PATCH 1/2] Persist the viewAll states for left menu items --- .../templates/homeFeed/LibraryFilterMenu.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx index d6d300be9..1ba9b468f 100644 --- a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx +++ b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx @@ -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({ + 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({ + key: `--labels-view-all`, + initialValue: false, + }) return ( Date: Wed, 26 Jul 2023 12:52:10 +0800 Subject: [PATCH 2/2] Fix typo on viewAll type --- .../web/components/templates/homeFeed/LibraryFilterMenu.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx index 1ba9b468f..9d1fe702b 100644 --- a/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx +++ b/packages/web/components/templates/homeFeed/LibraryFilterMenu.tsx @@ -198,7 +198,7 @@ function Subscriptions(props: LibraryFilterMenuProps): JSX.Element { function Labels(props: LibraryFilterMenuProps): JSX.Element { const { labels } = useGetLabelsQuery() - const [viewAll, setViewAll] = usePersistedState({ + const [viewAll, setViewAll] = usePersistedState({ key: `--labels-view-all`, initialValue: false, })