Skip to content

Commit

Permalink
Fix infinite spinner when opening public user's file in Reader
Browse files Browse the repository at this point in the history
There is no option to do so via UI but id someone manipulates/copies URL, it should redirect correctly.
  • Loading branch information
tnajdek committed Jul 2, 2024
1 parent ec1db8a commit 14bfcf9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/js/component/reader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 14bfcf9

Please sign in to comment.