Merge pull request #5902 from overleaf/ta-layout-local-storage

Fix pdf.layout value in local storage

GitOrigin-RevId: 1ff6ab51f51d2895b6e7305a36af57fb205c0fa3
This commit is contained in:
Timothée Alby 2021-11-30 15:53:59 +01:00 committed by Copybot
parent 970fd27165
commit 411886ba94

View file

@ -28,6 +28,13 @@ LayoutContext.Provider.propTypes = {
}).isRequired,
}
function setLayoutInLocalStorage(pdfLayout) {
localStorage.setItem(
'pdf.layout',
pdfLayout === 'sideBySide' ? 'split' : 'flat'
)
}
export function LayoutProvider({ children }) {
const { $scope } = useIdeContext()
@ -68,7 +75,7 @@ export function LayoutProvider({ children }) {
const newLayout = layout === 'sideBySide' ? 'flat' : 'sideBySide'
setView(newLayout === 'sideBySide' ? 'editor' : 'pdf')
setPdfLayout(newLayout)
localStorage.setItem('pdf.layout', newLayout)
setLayoutInLocalStorage(newLayout)
})
}, [setPdfLayout, setView])
@ -76,7 +83,7 @@ export function LayoutProvider({ children }) {
(newLayout, newView) => {
setPdfLayout(newLayout)
setView(newLayout === 'sideBySide' ? 'editor' : newView)
localStorage.setItem('pdf.layout', newLayout)
setLayoutInLocalStorage(newLayout)
},
[setPdfLayout, setView]
)