Skip to content

Commit

Permalink
Fix: Handle failed document preload for deleted representations (#968)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Press authored Mar 27, 2019
1 parent f5c4de4 commit 0a1d0ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/lib/viewers/doc/DocPreloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
PDFJS_WIDTH_PADDING_PX,
PDFJS_HEIGHT_PADDING_PX
} from '../../constants';
import api from '../../api';
import { setDimensions } from '../../util';
import { setDimensions, fetchRepresentationAsBlob } from '../../util';

const EXIF_COMMENT_TAG_NAME = 'UserComment'; // Read EXIF data from 'UserComment' tag
const EXIF_COMMENT_REGEX = /pdfWidth:([0-9.]+)pts,pdfHeight:([0-9.]+)pts,numPages:([0-9]+)/;
Expand Down Expand Up @@ -81,7 +80,7 @@ class DocPreloader extends EventEmitter {
this.containerEl = containerEl;

// Need to load image as a blob to read EXIF
return api.get(preloadUrlWithAuth, { type: 'blob' }).then((imgBlob) => {
return fetchRepresentationAsBlob(preloadUrlWithAuth).then((imgBlob) => {
if (this.checkDocumentLoaded()) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib/viewers/doc/__tests__/DocPreloader-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('lib/viewers/doc/DocPreloader', () => {

it('should set up preload DOM structure and bind image load handler', () => {
const imgSrc = 'https://someblobimgsrc/';
sandbox.stub(api, 'get').returns(Promise.resolve({}));
sandbox.stub(util, 'fetchRepresentationAsBlob').returns(Promise.resolve({}));
sandbox.stub(URL, 'createObjectURL').returns(imgSrc);
sandbox.stub(docPreloader, 'bindDOMListeners');

Expand Down

0 comments on commit 0a1d0ef

Please sign in to comment.