nextcloud / nextcloud/talk-desktop

Migrate off the OCA.Viewer global before Nextcloud 36

Open
#1,899 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
525
Forks
85
Avg merge
8h 5m
Merged PRs (30d)
35

Description

Talk Desktop reaches into the handler registry to render a handler's component itself:

  • src/talk/renderer/Viewer/ViewerApp.vue:23: window.OCA.Viewer.availableHandlers.find((handler) => handler.mimes.includes(file.mime))?.component

[!IMPORTANT]
This is the one place I found that needs more than a port. Handlers no longer expose a Vue
component. They register a tagname for a custom element they have defined on
window.customElements, which is what lets a handler be written in any framework. So there is
no component to pull out of the registry and mount.

Two ways out, and I would rather hear which fits Talk Desktop before adding anything:

  • pick the handler with getHandlers() and render its tagname as an element, passing the
    props a handler receives
    as attributes, which is what the viewer itself does
  • or use getViewer().open(nodes, file) and let the library render the modal, if the reason for
    rendering the component directly was the surrounding chrome rather than the file view

Happy to add something to the library if neither works.


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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/talk/renderer/Viewer/ViewerApp.vue:23 and read the @nextcloud/viewer migration guidance, especially getHandlers(), getViewer().open(), and the node requirements. Trace how the current viewer and surrounding chrome are used before choosing the rendering approach. Done means no OCA.Viewer access remains and the Talk Desktop viewer works with Nextcloud 36 APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
desktop, frontend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.