nextcloud / nextcloud/activity

Migrate off the OCA.Viewer global before Nextcloud 36

Open
#2,917 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
145
Forks
72
Avg merge
6d 9h
Merged PRs (30d)
42

Description

Activity opens file previews in the viewer:

  • src/components/activities/GenericActivity.vue:143: window.OCA.Viewer.mimetypes.includes(preview.mimeType)
  • src/components/activities/GenericActivity.vue:145: window.OCA.Viewer.open({ path })

mimetypes.includes(mime) becomes canView(node), which asks the registered handlers rather
than a flattened mime list, so a handler that decides on more than the mime type is answered
correctly too.

The path is being derived with filePath.replace(/^\/[^/]+\/files/, ''), which suggests a dav
path is already at hand. That is most of what building the node needs.


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/components/activities/GenericActivity.vue at lines 143 and 145, then read the @nextcloud/viewer migration README and the @nextcloud/files node API. Replace the OCA.Viewer usage with the registered-handler check and node-based viewer API described in the issue. Done means activity file previews open on Nextcloud 36 without the viewer app or compatibility shim.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.