Solutons Lounge

How to access OCA.Files JavaScript APIs in Nextcloud 28? – app dev


Hi everyone,
I am the developer of the HEIC/ HEIF Image Converter app and currently try to port it to Nextcloud 28, since I noticed that this time a simple version bump is not enough to get it running again.

In this application, I make heavy use of methods/ properties from the OCA.Files namespace, and it seems like using those is more or less deprecated.
As far as I am concerned, “modern” apps should use the methods of the separate NPM module: @nextcloud/files
While this approach seems to be working fine to register file actions I noticed that it doesn’t give me the same parameters in the handler.

Especially, I am missing the “context” parameter that was present on the legacy (?) OCA.Files.FileAction.registerAction() method’s “action” handler signature.
I used this context object to set the busy state of the files (context.fileList.showFileBusyState()) and trigger a reload (context.fileList.reload()) once my action was completed.
I guess that this is just not yet part of the new API, or am I missing something?
Maybe even out of scope for the NPM modules, because it’s too low level? I don’t know…

Anyway, the real problem that I have is that even once the whole Nextcloud website finished loading, I don’t have access to the old OCA.Files.App and OCA.Files.fileActions APIs anymore.
The only thing that is returned is this:

This is of course just a fraction of the old OCA.Files APIs.

Is this a bug, or am I doing something wrong here?
As you can see in my test case I am using the browser console, once everything has finished loading, but I also tried to access them from within my app, both using Util::addInitScript and Util::addScript.
In both cases the results were the same.

Edit: I am using Nextcloud 28.0.3 RC1 for my development setup.

Oh okay seems like i missed this part of the changelog. Thanks for the hint.
I think that’s a pretty drastic change, especially since those APIs weren’t deprecated before.

So what is the suggested alternative to set the busy state of a file or reload the fileList?
Is there any?

I’m not aware of a public API for that.

Oh wow I am really surprised and disappointed by that.
I had hoped that the existing public APIs had only been moved to a new repository, not completely removed without any deprecation notice before.

Is there any chance that a feature request to add those APIs to the new modules would be accepted?

I guess the only alternative that I have otherwise is to completely reload the page whenever I add a new file on the server side, right?

I am not a Files developer. An API might still exist, I’m just not aware of it.

Okay then I hope that somebody of the Files team might read this as well.
Or should I create an issue on Github for this?

You might want to ask your question here: https://cloud.nextcloud.com/call/4606076295. Maybe someone there can help you!

Sorry, I think you need to be logged in to see the room.

Okay thank you, but how can I register for this Nextcloud instance?
I don’t see any button to do so.



Source link

Exit mobile version