diff --git a/apps/comments/src/files-sidebar.ts b/apps/comments/src/files-sidebar.ts index 1eb4ae7519f..47ff8dfc1cb 100644 --- a/apps/comments/src/files-sidebar.ts +++ b/apps/comments/src/files-sidebar.ts @@ -11,7 +11,6 @@ import { t } from '@nextcloud/l10n' import wrap from '@vue/web-component-wrapper' import { createPinia, PiniaVuePlugin } from 'pinia' import Vue from 'vue' -import FilesSidebarTab from './views/FilesSidebarTab.vue' import { registerCommentsPlugins } from './comments-activity-tab.ts' __webpack_nonce__ = getCSPNonce() @@ -30,28 +29,20 @@ if (loadState('comments', 'activityEnabled', false) && OCA?.Activity?.registerSi iconSvgInline: MessageReplyText, order: 50, tagName, - enabled() { - if (!window.customElements.get(tagName)) { - setupSidebarTab() - } - return true + async onInit() { + const { default: FilesSidebarTab } = await import('./views/FilesSidebarTab.vue') + + Vue.use(PiniaVuePlugin) + Vue.mixin({ pinia: createPinia() }) + const webComponent = wrap(Vue, FilesSidebarTab) + // In Vue 2, wrap doesn't support disabling shadow. Disable with a hack + Object.defineProperty(webComponent.prototype, 'attachShadow', { + value() { return this }, + }) + Object.defineProperty(webComponent.prototype, 'shadowRoot', { + get() { return this }, + }) + window.customElements.define(tagName, webComponent) }, }) } - -/** - * Setup the sidebar tab as a web component - */ -function setupSidebarTab() { - Vue.use(PiniaVuePlugin) - Vue.mixin({ pinia: createPinia() }) - const webComponent = wrap(Vue, FilesSidebarTab) - // In Vue 2, wrap doesn't support disabling shadow. Disable with a hack - Object.defineProperty(webComponent.prototype, 'attachShadow', { - value() { return this }, - }) - Object.defineProperty(webComponent.prototype, 'shadowRoot', { - get() { return this }, - }) - window.customElements.define(tagName, webComponent) -} diff --git a/apps/comments/src/views/FilesSidebarTab.vue b/apps/comments/src/views/FilesSidebarTab.vue index 6c9e06ca254..ce9be4bf28b 100644 --- a/apps/comments/src/views/FilesSidebarTab.vue +++ b/apps/comments/src/views/FilesSidebarTab.vue @@ -11,24 +11,16 @@ import Comments from './Comments.vue' const props = defineProps<{ node?: INode + + // eslint-disable-next-line vue/no-unused-properties -- Required on the web component interface + active?: boolean // eslint-disable-next-line vue/no-unused-properties -- Required on the web component interface folder?: IFolder // eslint-disable-next-line vue/no-unused-properties -- Required on the web component interface view?: IView }>() -defineExpose({ setActive }) - const resourceId = computed(() => props.node?.fileid) - -/** - * Set this tab as active - * - * @param active - The active state - */ -function setActive(active: boolean) { - return active -}