From df17496c69f78bddc401910e93f0276ea4d40053 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 24 Jun 2022 09:15:31 -0700 Subject: [PATCH 1/4] Use persisted state instead of preferences data for library layout These visual settings should be per device not set in preferences having them in preferences requires an API call and will make them flicker when loaded. --- .../web/components/templates/homeFeed/HomeFeedContainer.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index 5e02fb680..e2c7f75ba 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -502,9 +502,7 @@ function HomeFeedGrid(props: HomeFeedContentProps): JSX.Element { const { preferencesData, isValidating: isValidatingPreferences } = useGetUserPreferences() - const [layout, setLayout] = useState( - (preferencesData?.libraryLayoutType as LayoutType) || 'GRID_LAYOUT' - ) + const [layout, setLayout] = usePersistedState({ key: 'libraryLayout', initialValue: 'GRID_LAYOUT' }) const [showRemoveLinkConfirmation, setShowRemoveLinkConfirmation] = useState(false) const [linkToRemove, setLinkToRemove] = useState() From a6455d8359bda1f3165772c3261818a10d81611c Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Fri, 24 Jun 2022 09:38:32 -0700 Subject: [PATCH 2/4] We dont need to wait for preferences data to load before showing the grid selector now --- .../templates/homeFeed/HomeFeedContainer.tsx | 41 ++++++++----------- 1 file changed, 17 insertions(+), 24 deletions(-) diff --git a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx index e2c7f75ba..bc5727c7b 100644 --- a/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx +++ b/packages/web/components/templates/homeFeed/HomeFeedContainer.tsx @@ -499,10 +499,7 @@ type HomeFeedContentProps = { function HomeFeedGrid(props: HomeFeedContentProps): JSX.Element { const { viewerData } = useGetViewerQuery() - - const { preferencesData, isValidating: isValidatingPreferences } = - useGetUserPreferences() - const [layout, setLayout] = usePersistedState({ key: 'libraryLayout', initialValue: 'GRID_LAYOUT' }) + const [layout, setLayout] = usePersistedState({ key: 'libraryLayout', initialValue: 'GRID_LAYOUT' }) const [showRemoveLinkConfirmation, setShowRemoveLinkConfirmation] = useState(false) const [linkToRemove, setLinkToRemove] = useState() @@ -578,26 +575,22 @@ function HomeFeedGrid(props: HomeFeedContentProps): JSX.Element { justifyContent: 'center', }} > - {!isValidatingPreferences && ( - <> - { - updateLayout('GRID_LAYOUT') - }} - > - - - { - updateLayout('LIST_LAYOUT') - }} - > - - - - )} + { + updateLayout('GRID_LAYOUT') + }} + > + + + { + updateLayout('LIST_LAYOUT') + }} + > + +