File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ import { AuthorsList } from '../../../components'
2121import { Deposition } from '../../../types/zenodo'
2222import { fetchDataDeposition , fetchPreprintIdentifier } from '../../../actions'
2323import ErrorOrTrack from './error-or-track'
24+ import { alertOnError } from '../../../actions/server-utils'
2425
2526pdfjs . GlobalWorkerOptions . workerSrc = `//unpkg.com/pdfjs-dist@${ pdfjs . version } /build/pdf.worker.min.mjs`
2627
@@ -111,10 +112,6 @@ const PreprintViewer = ({
111112 } )
112113 } , [ track , preprint . pk , submissionType ] )
113114
114- const onDocumentLoadSuccess = ( pdf : PDFDocumentProxy ) : void => {
115- setPdf ( pdf )
116- }
117-
118115 useEffect ( ( ) => {
119116 if ( pdf && ! hidePdfOutline ) {
120117 pdf . getOutline ( ) . then ( setPdfOutline ) . catch ( console . error )
@@ -201,7 +198,16 @@ const PreprintViewer = ({
201198 < div ref = { containerRef } style = { { width : '100%' } } >
202199 < Document
203200 file = { preprint . versions [ 0 ] . public_download_url }
204- onLoadSuccess = { onDocumentLoadSuccess }
201+ onLoadSuccess = { ( pdf : PDFDocumentProxy ) => setPdf ( pdf ) }
202+ onLoadError = { ( error ) =>
203+ alertOnError ( {
204+ endpoint : preprint . versions [ 0 ] . public_download_url ,
205+ status : 'n/a' ,
206+ statusText : 'unknown' ,
207+ method : 'GET' ,
208+ apiError : error . message ,
209+ } )
210+ }
205211 loading = {
206212 < Flex
207213 sx = { {
You can’t perform that action at this time.
0 commit comments