From a8d1a8f6b3c2014254918bc7532cfd0becb3d402 Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 13 Jun 2024 16:11:42 +0800 Subject: [PATCH] Better return from PDF to library --- .../templates/article/PdfArticleContainer.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/web/components/templates/article/PdfArticleContainer.tsx b/packages/web/components/templates/article/PdfArticleContainer.tsx index d35046312..dfbbcabf5 100644 --- a/packages/web/components/templates/article/PdfArticleContainer.tsx +++ b/packages/web/components/templates/article/PdfArticleContainer.tsx @@ -35,8 +35,9 @@ export default function PdfArticleContainer( const containerRef = useRef(null) const [notebookKey, setNotebookKey] = useState(uuidv4()) const [noteTarget, setNoteTarget] = useState(undefined) - const [noteTargetPageIndex, setNoteTargetPageIndex] = - useState(undefined) + const [noteTargetPageIndex, setNoteTargetPageIndex] = useState< + number | undefined + >(undefined) const highlightsRef = useRef([]) const annotationOmnivoreId = (annotation: Annotation): string | undefined => { @@ -448,6 +449,11 @@ export default function PdfArticleContainer( document.dispatchEvent(new Event('openOriginalArticle')) break case 'u': + const navReturn = window.sessionStorage.getItem('nav-return') + if (navReturn) { + window.location.assign(navReturn) + return + } const query = window.sessionStorage.getItem('q') if (query) { window.location.assign(`/home?${query}`)