Merge pull request #4054 from omnivore-app/fix/navigation-return
Return to previous library path after reading
This commit is contained in:
@ -93,6 +93,7 @@ export function LibraryGridCard(props: LinkedItemCardProps): JSX.Element {
|
||||
props.setIsChecked(props.item.id, !props.isChecked)
|
||||
return
|
||||
}
|
||||
window.sessionStorage.setItem('nav-return', router.asPath)
|
||||
if (event.metaKey || event.ctrlKey) {
|
||||
window.open(
|
||||
`/${props.viewer.profile.username}/${props.item.slug}`,
|
||||
|
||||
@ -100,6 +100,7 @@ export function LibraryListCard(props: LinkedItemCardProps): JSX.Element {
|
||||
props.setIsChecked(props.item.id, !props.isChecked)
|
||||
return
|
||||
}
|
||||
window.sessionStorage.setItem('nav-return', router.asPath)
|
||||
if (event.metaKey || event.ctrlKey) {
|
||||
window.open(
|
||||
`/${props.viewer.profile.username}/${props.item.slug}`,
|
||||
|
||||
@ -89,9 +89,14 @@ export default function Home(): JSX.Element {
|
||||
// return
|
||||
// }
|
||||
// }
|
||||
const navReturn = window.sessionStorage.getItem('nav-return')
|
||||
if (navReturn) {
|
||||
router.push(navReturn)
|
||||
return
|
||||
}
|
||||
|
||||
const query = window.sessionStorage.getItem('q')
|
||||
router.push(`/home?${query}`)
|
||||
// router.push(`/home`)
|
||||
}, [router, viewerData, article])
|
||||
|
||||
const goPreviousOrHome = useCallback(() => {
|
||||
@ -298,6 +303,11 @@ export default function Home(): JSX.Element {
|
||||
name: 'Return to library',
|
||||
shortcut: ['u'],
|
||||
perform: () => {
|
||||
const navReturn = window.sessionStorage.getItem('nav-return')
|
||||
if (navReturn) {
|
||||
router.push(navReturn)
|
||||
return
|
||||
}
|
||||
const query = window.sessionStorage.getItem('q')
|
||||
if (query) {
|
||||
router.push(`/home?${query}`)
|
||||
|
||||
@ -42,7 +42,14 @@ const generateActions = (router: NextRouter) => {
|
||||
name: 'Go to Home (Library) ',
|
||||
shortcut: ['g', 'h'],
|
||||
keywords: 'go home',
|
||||
perform: () => router?.push('/home'),
|
||||
perform: () => {
|
||||
const navReturn = window.sessionStorage.getItem('nav-return')
|
||||
if (navReturn) {
|
||||
router.push(navReturn)
|
||||
return
|
||||
}
|
||||
router?.push('/home')
|
||||
},
|
||||
},
|
||||
{
|
||||
id: 'lightTheme',
|
||||
|
||||
Reference in New Issue
Block a user