nextcloud / nextcloud/files_emailviewer
Migrate off the OCA.Viewer global before Nextcloud 36
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5
- Forks
- 1
- Avg merge
- 8h 44m
- Merged PRs (30d)
- 5
Description
files_emailviewer registers a handler and delegates rendering to the pdf handler:
src/main.js:17:OCA.Viewer.availableHandlers.find((handler) => handler.id === 'pdf')src/views/EmailView.vue:35:OCA.Viewer.mimetypes.includes(fileInfo.mime)src/views/EmailView.vue:57:OCA.Viewer.openWith('pdf', { ... })
Three separate things change here.
Handlers are custom elements now, not Vue components handed to the viewer. You define the
element on window.customElements and register its tagname, and enabled(nodes) replaces the
mimes array. See the
registration walkthrough.
Looking a handler up by id is getHandlers().get('pdf'), and openWith('pdf', { … }) becomes
getViewer().open(nodes, file, options, 'pdf') with the handler id as the fourth argument.
mimetypes.includes(mime) becomes canView(node).
[!NOTE]
Registration depends on files_pdfviewer having registered first, which is now a matter of
import order rather than of the viewer app having loaded. nextcloud/files_pdfviewer#1572 is
the matching issue there, worth doing in that order.
[!WARNING]
Without this, emails stop opening in the viewer entirely.
OCA.Viewer is gone in Viewer 7.0.0. The viewer ships as the
@nextcloud/viewer library rather than a
bundled app, and nextcloud/server#63954 removes the viewer app from Nextcloud 36 altogether.
Roughly what it looks like:
import { canView, getViewer } from '@nextcloud/viewer'
// OCA.Viewer.open({ path }) / ({ fileInfo, list })
getViewer().open(nodes, file) // @nextcloud/files nodes
getViewer().openFolder(folder, file) // when a path is all you have, let it fetch
// OCA.Viewer.mimetypes.includes(mime) / availableHandlers
canView(node)
The part that is not a rename is that the viewer takes @nextcloud/files nodes now, not
fileinfo objects or path strings. Importing the package is also all it takes to get the viewer
onto the page: no LoadViewer event to dispatch, and nothing to check about whether the app is
enabled.
[!IMPORTANT]
There is no compatibility shim, which was a deliberate call, so this is a real port rather
than a rename. Nothing breaks until the server PR lands; after that these calls throw on
Nextcloud 36.
[!TIP]
The developer manual covers the migration under
Critical changes
(being added in nextcloud/documentation#15597), and the
README
has the full before/after table. Happy to help with the port, just ping me.
👾 This issue was written with the help of Claude Code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with src/main.js:17 and src/views/EmailView.vue:35, then read the nextcloud-viewer migration README and registration walkthrough. Replace the OCA.Viewer integration with @nextcloud/viewer and @nextcloud/files nodes, including custom-element handler registration and the updated viewer APIs. Done means emails still open in the PDF viewer on the post-Viewer 7.0.0 setup without relying on the viewer app or OCA.Viewer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100