66import type { INode } from '@nextcloud/files'
77
88import moment from '@nextcloud/moment'
9- import { createPinia , PiniaVuePlugin } from 'pinia'
10- import Vue , { type ComponentPublicInstance } from 'vue'
9+ import { createPinia } from 'pinia'
10+ import { createApp , type ComponentPublicInstance } from 'vue'
1111import logger from './logger.ts'
1212import { getComments } from './services/GetComments.ts'
1313
14- Vue . use ( PiniaVuePlugin )
15-
16- let ActivityTabPluginView
17- let ActivityTabPluginInstance
18-
1914/**
2015 * Register the comments plugins for the Activity sidebar
2116 */
2217export function registerCommentsPlugins ( ) {
18+ let app
19+
2320 window . OCA . Activity . registerSidebarAction ( {
2421 mount : async ( el : HTMLElement , { node, reload } : { node : INode , reload : ( ) => void } ) => {
2522 const pinia = createPinia ( )
2623
27- if ( ! ActivityTabPluginView ) {
24+ if ( ! app ) {
2825 const { default : ActivityCommentAction } = await import ( './views/ActivityCommentAction.vue' )
29- // @ts -expect-error Types are broken for Vue2
30- ActivityTabPluginView = Vue . extend ( ActivityCommentAction )
26+ app = createApp (
27+ ActivityCommentAction ,
28+ {
29+ reloadCallback : reload ,
30+ resourceId : node . fileid ,
31+ } ,
32+ )
3133 }
32- ActivityTabPluginInstance = new ActivityTabPluginView ( {
33- el,
34- pinia,
35- propsData : {
36- reloadCallback : reload ,
37- resourceId : node . fileid ,
38- } ,
39- } )
34+ app . use ( pinia )
35+ app . mount ( el )
4036 logger . info ( 'Comments plugin mounted in Activity sidebar action' , { node } )
4137 } ,
4238 unmount : ( ) => {
4339 // destroy previous instance if available
44- if ( ActivityTabPluginInstance ) {
45- ActivityTabPluginInstance . $destroy ( )
46- }
40+ app ?. unmount ( )
4741 } ,
4842 } )
4943
@@ -57,26 +51,25 @@ export function registerCommentsPlugins() {
5751 )
5852 logger . debug ( 'Loaded comments' , { node, comments } )
5953 const { default : CommentView } = await import ( './views/ActivityCommentEntry.vue' )
60- // @ts -expect-error Types are broken for Vue2
61- const CommentsViewObject = Vue . extend ( CommentView )
6254
6355 return comments . map ( ( comment ) => ( {
6456 _CommentsViewInstance : undefined as ComponentPublicInstance | undefined ,
6557
6658 timestamp : moment ( comment . props ?. creationDateTime ) . toDate ( ) . getTime ( ) ,
6759
6860 mount ( element : HTMLElement , { reload } ) {
69- this . _CommentsViewInstance = new CommentsViewObject ( {
70- el : element ,
71- propsData : {
61+ this . _CommentsViewInstance = createApp (
62+ CommentView ,
63+ {
7264 comment,
7365 resourceId : node . fileid ,
7466 reloadCallback : reload ,
7567 } ,
76- } )
68+ )
69+ this . _CommentsViewInstance . mount ( el )
7770 } ,
7871 unmount ( ) {
79- this . _CommentsViewInstance ?. $destroy ( )
72+ this . _CommentsViewInstance ?. unmount ( )
8073 } ,
8174 } ) )
8275 } )
0 commit comments