Skip to content

Commit

Permalink
fix: move to addInitScript
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Sep 6, 2023
1 parent 0c2751e commit 0eb23bb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/Listeners/FilesLoadAdditionalScriptsListener.php
Expand Up @@ -45,6 +45,7 @@ public function handle(Event $event): void {
return;
}

\OCP\Util::addInitScript('text', 'text-init');
\OCP\Util::addScript('text', 'text-files');

$this->initialStateProvider->provideState();
Expand Down
9 changes: 1 addition & 8 deletions src/files.js
Expand Up @@ -21,11 +21,10 @@
*/
import { linkTo } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
import { registerFileListHeaders, registerDavProperty } from '@nextcloud/files'
import Vue from 'vue'

import { logger } from './helpers/logger.js'
import { registerFileActionFallback, FilesWorkspaceHeader } from './helpers/files.js'
import { registerFileActionFallback } from './helpers/files.js'
import FilesSettings from './views/FilesSettings.vue'
import store from './store/index.js'

Expand All @@ -35,9 +34,6 @@ __webpack_public_path__ = linkTo('text', 'js/') // eslint-disable-line
const workspaceAvailable = loadState('text', 'workspace_available')
const workspaceEnabled = loadState('text', 'workspace_enabled')

registerDavProperty('nc:rich-workspace', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('nc:rich-workspace-file', { nc: 'http://nextcloud.org/ns' })

document.addEventListener('DOMContentLoaded', () => {
if (typeof OCA.Viewer === 'undefined') {
logger.error('Viewer app is not installed')
Expand All @@ -59,9 +55,6 @@ document.addEventListener('DOMContentLoaded', () => {
}

})
if (workspaceAvailable) {
registerFileListHeaders(FilesWorkspaceHeader)
}

OCA.Text = {
RichWorkspaceEnabled: workspaceEnabled,
Expand Down
12 changes: 12 additions & 0 deletions src/init.js
@@ -0,0 +1,12 @@
import { registerFileListHeaders, registerDavProperty } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'
import { FilesWorkspaceHeader } from './helpers/files.js'

const workspaceAvailable = loadState('text', 'workspace_available')

registerDavProperty('nc:rich-workspace', { nc: 'http://nextcloud.org/ns' })
registerDavProperty('nc:rich-workspace-file', { nc: 'http://nextcloud.org/ns' })

if (workspaceAvailable) {
registerFileListHeaders(FilesWorkspaceHeader)
}
1 change: 1 addition & 0 deletions webpack.config.js
Expand Up @@ -8,6 +8,7 @@ webpackConfig.entry = {
public: path.join(__dirname, 'src', 'public.js'),
viewer: path.join(__dirname, 'src', 'viewer.js'),
editors: path.join(__dirname, 'src', 'editor.js'),
init: path.join(__dirname, 'src', 'init.js'),
}

webpackConfig.output.chunkFilename = '[id].js?v=[contenthash]'
Expand Down

0 comments on commit 0eb23bb

Please sign in to comment.