diff --git a/src/init.ts b/src/init.ts index ba1efb614..d6d89b361 100644 --- a/src/init.ts +++ b/src/init.ts @@ -12,3 +12,10 @@ registerViewerAction() window.OCA = window.OCA ?? {} window.OCA.Viewer = new ViewerService() window.OCA.Viewer.version = appVersion + +// Eagerly register any handlers queued before the viewer was initialized. +// This must happen synchronously so that OCA.Viewer.mimetypes is complete +// before the file action's enabled() callback is evaluated by the files app. +if (window._oca_viewer_handlers) { + window._oca_viewer_handlers.forEach(handler => window.OCA.Viewer.registerHandler(handler)) +}