-
Notifications
You must be signed in to change notification settings - Fork 344
feat(content-preview): pass preloadUrlMap to enable prefetched image … #4411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
|
WalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🧰 Additional context used🧠 Learnings (1)📓 Common learnings⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
🔇 Additional comments (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
src/elements/content-preview/ContentPreview.js (1)
128-128: LGTM! Consider more specific typing as a future enhancement.The optional
preloadUrlMapprop is correctly typed and follows the established pattern. The genericObjecttype is acceptable and consistent with similar props in this file (e.g.,boxAnnotations,fileOptions).Optional: More specific type definition
If the structure of
preloadUrlMapis known, consider defining a more specific Flow type:type PreloadUrlMap = { [format: string]: { [pageNumber: number]: string } };Then update the prop:
- preloadUrlMap?: Object, + preloadUrlMap?: PreloadUrlMap,This would provide better type safety and documentation, but is not required for the current implementation.
📜 Review details
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
src/elements/content-preview/ContentPreview.jssrc/elements/content-preview/__tests__/ContentPreview.test.js
🧰 Additional context used
🧬 Code graph analysis (1)
src/elements/content-preview/__tests__/ContentPreview.test.js (1)
src/elements/content-preview/ContentPreview.js (3)
props(292-302)props(323-323)props(378-378)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: lint_test_build
- GitHub Check: semgrep-cloud-platform/scan
- GitHub Check: Summary
🔇 Additional comments (3)
src/elements/content-preview/ContentPreview.js (2)
815-815: LGTM!The prop is correctly destructured from
this.propsand follows the established pattern in this method.
859-859: LGTM!The
preloadUrlMapis correctly added to the preview options object and will be passed to the preview SDK. This follows the established pattern for optional configuration props.src/elements/content-preview/__tests__/ContentPreview.test.js (1)
448-468: LGTM! Well-structured test case.The test correctly verifies that
preloadUrlMapis passed through topreview.show()when provided. The test follows the established pattern in this file and provides a clear example of the expected data structure.
| [name: string]: TargetingApi, | ||
| }, | ||
| previewLibraryVersion: string, | ||
| preloadUrlMap?: Object, |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
The current approach is to pass the generated token as part of the preview metadata in file cache which is already supported here. |
…optimization
Summary
Adds preloadUrlMap prop to ContentPreview and passes it to the preview SDK.
This enables the preview SDK to use prefetched image URLs from the backend, avoiding redundant API calls for document first pages that were already prefetched. The prop is optional and backward compatible.
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.