Repository navigation
Conversation
Image placeholders are sized from attachment metadata. Creating the intersection observer before that metadata resolves makes every placeholder look visible, so all images load immediately instead of lazily. Assisted-by: Devin:adaptive Signed-off-by: Man Alin <whoalin414@gmail.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
77c0e7e to
4073585
Compare
There was a problem hiding this comment.
Thanks, the fix itself looks right. A few comments before merging:
-
Move
setupResizeObserver()before the await. Right nowwrapperWidthis still 0 when theIntersectionObserveris created, soblurhashSizeyields a negative width and the placeholder only gets its real height if theResizeObservercallback happens to run first. Starting theResizeObserverbefore awaiting the metadata measures the wrapper while the attachment list loads and removes that dependency:async mounted() { this.attachmentPromise = this.$attachmentResolver.resolve(this.src) this.setupResizeObserver() await this.loadAttachmentMetadata() if (this.isUnmounted) { return } …
-
Guard against unmounting during the await. If the image node is removed while the attachment list is still loading,
beforeUnmounthas already run, andmounted()then creates anIntersectionObserverthat is never disconnected. A flag set inbeforeUnmount(see code snippet as above) avoids that. -
Please replace the unit test with an end-to-end test. The Vitest spec mocks every node view prop and only checks when the
IntersectionObserverconstructor is called, so it's tied to the implementation rather than the behaviour. What we want to guarantee is that images below the fold aren't requested until they're scrolled into view. That needs real layout, so it belongs in Playwright, e.g.playwright/e2e/nodes/images.spec.ts. It needs the photos app to be installed in Playwright and enabled in the test in question. See e.g. how it's done for thefiles_lockapp in Playwright.
|
@whoalin1 if you don't think you find time to address the review comments, you can also give me write permissions to the branch and I can take over. |
📝 Summary
Image placeholders are sized from attachment metadata, but the lazy-loading intersection observer was created before that metadata resolved. At that point every placeholder was still small enough to intersect the viewport, so all images were loaded immediately. Waiting for the metadata before creating the observer lets the placeholder reach its real size first, restoring deferred loading for off-screen images.
🖼️ Screenshots
Not applicable: this changes loading timing rather than visible UI.
🚧 TODO
🏁 Checklist
npx eslint src/nodes/ImageView.vue src/tests/nodes/ImageViewLazyLoading.spec.tspassed)Validation
vue-tsc --noEmitpassedNot run: live Nextcloud validation or Playwright/Cypress end-to-end tests, because no live Nextcloud instance was available. Concrete manual validation steps: open a long Text document with several below-the-fold images on a remote server, confirm off-screen image previews are not requested immediately, then scroll and confirm each image loads as it approaches the viewport.
🤖 AI (if applicable)
Implemented and validated with Devin assistance; the contributor reviewed and submits this pull request.