fix(attachments): don't preview attachments when viewer app is disabled - #13491
fix(attachments): don't preview attachments when viewer app is disabled#13491hamza221 wants to merge 1 commit into
Conversation
|
@coderabbitai review |
✅ Action performedReview finished.
|
📝 WalkthroughWalkthroughThe page controller now exposes viewer availability in the initial state. Frontend initialization stores this value in Pinia. ChangesViewer availability
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: 🟡 Moderate · up to Attachment rendering can fail when the viewer app is unavailable because preview filtering may access a missing viewer object. The PR is not merge-ready until this case is guarded and covered. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
src/mixins/AttachmentMixin.js (1)
25-33: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick winGuard the Viewer namespace before filtering MIME types.
When
viewer_availableis absent,src/init.jsLine 119 defaultsviewerAvailabletotrue. IfOCA.Vieweris absent, Line 33 dereferences an unavailable object and prevents attachment rendering. CheckglobalThis.OCA?.Viewerbefore filtering. Add a test withviewerAvailableset totrueandglobal.OCA = {}.Proposed fix
previewableFileInfos() { - if (!this.viewerAvailable) { + const viewer = globalThis.OCA?.Viewer + if (!this.viewerAvailable || !viewer) { return [] } return this.fileInfos.filter((fileInfo) => (fileInfo.mime.startsWith('image/') || fileInfo.mime.startsWith('video/') || fileInfo.mime.startsWith('audio/') || fileInfo.mime === 'application/pdf') - && OCA.Viewer.mimetypes.includes(fileInfo.mime)) + && viewer.mimetypes.includes(fileInfo.mime)) },
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: da5d58cb-f178-445d-9618-d26c2a1e3c60
📒 Files selected for processing (7)
lib/Controller/PageController.phpsrc/init.jssrc/mixins/AttachmentMixin.jssrc/store/mainStore.jssrc/store/mainStore/actions.jssrc/tests/unit/mixins/AttachmentMixin.spec.jstests/Unit/Controller/PageControllerTest.php
ChristophWurst
left a comment
There was a problem hiding this comment.
How about a check for the global OCA.Viewer? Wouldn't that be easier?
Sure |
|
/backport to stable5.10 |
|
/backport to stable5.11 |
Signed-off-by: Hamza <hamzamahjoubi221@gmail.com>
18f4435 to
5cd0b5e
Compare
fix #13460
🤖 AI (if applicable)
tests
Summary by CodeRabbit
Bug Fixes
Tests