1- /**
1+ /*!
22 * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
33 * SPDX-License-Identifier: AGPL-3.0-or-later
44 */
55
6+ import type { INode } from '@nextcloud/files'
7+
68import moment from '@nextcloud/moment'
79import { createPinia , PiniaVuePlugin } from 'pinia'
810import Vue , { type ComponentPublicInstance } from 'vue'
@@ -19,7 +21,7 @@ let ActivityTabPluginInstance
1921 */
2022export function registerCommentsPlugins ( ) {
2123 window . OCA . Activity . registerSidebarAction ( {
22- mount : async ( el , { fileInfo , reload } ) => {
24+ mount : async ( el : HTMLElement , { node , reload } : { node : INode , reload : ( ) => void } ) => {
2325 const pinia = createPinia ( )
2426
2527 if ( ! ActivityTabPluginView ) {
@@ -32,10 +34,10 @@ export function registerCommentsPlugins() {
3234 pinia,
3335 propsData : {
3436 reloadCallback : reload ,
35- resourceId : fileInfo . id ,
37+ resourceId : node . fileid ,
3638 } ,
3739 } )
38- logger . info ( 'Comments plugin mounted in Activity sidebar action' , { fileInfo } )
40+ logger . info ( 'Comments plugin mounted in Activity sidebar action' , { node } )
3941 } ,
4042 unmount : ( ) => {
4143 // destroy previous instance if available
@@ -45,9 +47,15 @@ export function registerCommentsPlugins() {
4547 } ,
4648 } )
4749
48- window . OCA . Activity . registerSidebarEntries ( async ( { fileInfo, limit, offset } ) => {
49- const { data : comments } = await getComments ( { resourceType : 'files' , resourceId : fileInfo . id } , { limit, offset } )
50- logger . debug ( 'Loaded comments' , { fileInfo, comments } )
50+ window . OCA . Activity . registerSidebarEntries ( async ( { node, limit, offset } : { node : INode , limit ?: number , offset ?: number } ) => {
51+ const { data : comments } = await getComments (
52+ { resourceType : 'files' , resourceId : node . fileid } ,
53+ {
54+ limit,
55+ offset : offset ?? 0 ,
56+ } ,
57+ )
58+ logger . debug ( 'Loaded comments' , { node, comments } )
5159 const { default : CommentView } = await import ( './views/ActivityCommentEntry.vue' )
5260 // @ts -expect-error Types are broken for Vue2
5361 const CommentsViewObject = Vue . extend ( CommentView )
@@ -62,7 +70,7 @@ export function registerCommentsPlugins() {
6270 el : element ,
6371 propsData : {
6472 comment,
65- resourceId : fileInfo . id ,
73+ resourceId : node . fileid ,
6674 reloadCallback : reload ,
6775 } ,
6876 } )
0 commit comments