-
Notifications
You must be signed in to change notification settings - Fork 25
feat: only request thumnail if server support is guaranteed #874
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
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.
Pull Request Overview
This PR ensures that thumbnails are only requested when the server explicitly indicates preview support.
- Removes server-side capability checks in
PreviewServicein favor of ahasPreviewflag on resources - Adds a
hasPreviewproperty to the resource interface and populates it from WebDAV props - Cleans up test setup by dropping the unused
capabilityStore
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/web-pkg/tests/unit/services/previewService.spec.ts | Removed capabilityStore injection from test wrapper |
| packages/web-pkg/src/services/preview/previewService.ts | Simplified loadPreview to rely on resource.hasPreview |
| packages/web-client/src/webdav/constants/dav.ts | Introduced HasPreview DAV property |
| packages/web-client/src/helpers/resource/types.ts | Added optional hasPreview method to Resource |
| packages/web-client/src/helpers/resource/functions.ts | Implemented hasPreview in buildResource |
Comments suppressed due to low confidence (2)
packages/web-pkg/tests/unit/services/previewService.spec.ts:211
- Tests no longer mock
capabilityStore, but also need to stubresource.hasPreview. Add a defaulthasPreview: () => true(or false) in the test wrapper to cover the new preview logic.
authStore
packages/web-client/src/helpers/resource/types.ts:73
- [nitpick]
hasPreviewis critical for preview logic, so it should be a required method (hasPreview(): boolean) rather than optional to prevent missing implementations.
hasPreview?(): boolean
| resource.type !== 'folder' && | ||
| resource.extension && | ||
| resource.canDownload() && | ||
| resource.hasPreview() |
Copilot
AI
Jun 27, 2025
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.
Calling resource.hasPreview() without guarding against hasPreview being undefined can cause a runtime error. Consider using resource.hasPreview?.() or making the method non-optional.
| resource.hasPreview() | |
| resource.hasPreview?.() |
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.
we need to implement it for the other interfaces as well
|
Blocked by opencloud-eu/opencloud#1133 |
# Conflicts: # tests/e2e/support/api/graph/userManagement.ts
…olled by the browser
| mimeType: space.spaceImageData.file.mimeType, | ||
| type: 'file', | ||
| webDavPath: urlJoin(space.webDavPath, '.space', space.spaceImageData.name), | ||
| hasPreview: () => true, |
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.
this correct (space images always have preview)
|
Needs OPENCLOUD_COMMIT_ID bump after opencloud-eu/opencloud#1257 is merged |
JammingBen
left a 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.
2 nitpicks, rest LGTM 👍
Co-authored-by: Jannik Stehle <50302941+JammingBen@users.noreply.github.com>
JammingBen
left a 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.
👍 Type checks need a fix though.
Description
Related Issue
How Has This Been Tested?
Types of changes