From 14bfcf9d9b609ad3ecc8ca3019c00973b0bb5fe3 Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Tue, 2 Jul 2024 13:23:06 +0200 Subject: [PATCH] Fix infinite spinner when opening public user's file in Reader There is no option to do so via UI but id someone manipulates/copies URL, it should redirect correctly. --- src/js/component/reader.jsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/js/component/reader.jsx b/src/js/component/reader.jsx index e2d494bc..70c76adb 100644 --- a/src/js/component/reader.jsx +++ b/src/js/component/reader.jsx @@ -372,6 +372,15 @@ const Reader = () => { }, [attachmentItem, attachmentKey, dispatch]); + useEffect(() => { + if (libraryKey !== userLibraryKey && libraryKey.startsWith('u')) { + // Opening reader for an item in a public user library is not supported. + // It cannot work because API does not include 'enclosure' link for attachments in public user libraries. + // Redirect to item details instead. + dispatch(navigate({ view: 'item-details', location: null })); + } + }, [dispatch, libraryKey, userLibraryKey]); + // Fetch all child items (annotations). This effect will execute multiple times for each page of annotations useEffect(() => { if (state.isRouteConfirmed && !isFetching && !isFetched) {