Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/elements/content-preview/ContentPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ type Props = {
[name: string]: TargetingApi,
},
previewLibraryVersion: string,
preloadUrlMap?: Object,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is how we want to do this. Take a look at the comments on the corresponding PR in EUA.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am going to close this PR as we won't need anything to be done here. The current approach is to pass the generated token as part of the preview metadata in file cache which is already supported here.

requestInterceptor?: Function,
responseInterceptor?: Function,
sharedLink?: string,
Expand Down Expand Up @@ -811,6 +812,7 @@ class ContentPreview extends React.PureComponent<Props, State> {
onAnnotatorEvent,
onAnnotator,
onContentInsightsEventReport,
preloadUrlMap,
previewExperiences,
showAnnotationsControls,
token: tokenOrTokenFunction,
Expand Down Expand Up @@ -854,6 +856,7 @@ class ContentPreview extends React.PureComponent<Props, State> {
header: 'none',
headerElement: `#${this.id} .bcpr-PreviewHeader`,
experiences: previewExperiences,
preloadUrlMap,
showAnnotations: this.canViewAnnotations(),
showAnnotationsControls,
showDownload: this.canDownload(),
Expand Down
22 changes: 22 additions & 0 deletions src/elements/content-preview/__tests__/ContentPreview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,28 @@ describe('elements/content-preview/ContentPreview', () => {
);
});

test('should pass preloadUrlMap to preview.show() when provided', async () => {
const preloadUrlMap = {
jpg: { 1: 'https://api.box.com/image1.jpg' },
webp: { 1: 'https://api.box.com/image2.webp', 2: 'https://api.box.com/image3.webp' },
};
const wrapper = getWrapper({ ...props, preloadUrlMap });

wrapper.setState({ file });

const instance = wrapper.instance();

await instance.loadPreview();

expect(instance.preview.show).toHaveBeenCalledWith(
file.id,
expect.any(Function),
expect.objectContaining({
preloadUrlMap,
}),
);
});

test.each`
called | showAnnotationsControls
${true} | ${true}
Expand Down