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.
This commit is contained in:
Jackson Harper 2022-06-24 09:15:31 -07:00
parent a0168adc3c
commit df17496c69

View file

@ -502,9 +502,7 @@ function HomeFeedGrid(props: HomeFeedContentProps): JSX.Element {
const { preferencesData, isValidating: isValidatingPreferences } =
useGetUserPreferences()
const [layout, setLayout] = useState<LayoutType>(
(preferencesData?.libraryLayoutType as LayoutType) || 'GRID_LAYOUT'
)
const [layout, setLayout] = usePersistedState({ key: 'libraryLayout', initialValue: 'GRID_LAYOUT' })
const [showRemoveLinkConfirmation, setShowRemoveLinkConfirmation] =
useState(false)
const [linkToRemove, setLinkToRemove] = useState<LibraryItem>()