Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions apps/comments/src/comments-activity-tab.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/**
/*!
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

import type { INode } from '@nextcloud/files'

import moment from '@nextcloud/moment'
import { createPinia, PiniaVuePlugin } from 'pinia'
import Vue, { type ComponentPublicInstance } from 'vue'
Expand All @@ -19,7 +21,7 @@ let ActivityTabPluginInstance
*/
export function registerCommentsPlugins() {
window.OCA.Activity.registerSidebarAction({
mount: async (el, { fileInfo, reload }) => {
mount: async (el: HTMLElement, { node, reload }: { node: INode, reload: () => void }) => {
const pinia = createPinia()

if (!ActivityTabPluginView) {
Expand All @@ -32,10 +34,10 @@ export function registerCommentsPlugins() {
pinia,
propsData: {
reloadCallback: reload,
resourceId: fileInfo.id,
resourceId: node.fileid,
},
})
logger.info('Comments plugin mounted in Activity sidebar action', { fileInfo })
logger.info('Comments plugin mounted in Activity sidebar action', { node })
},
unmount: () => {
// destroy previous instance if available
Expand All @@ -45,9 +47,15 @@ export function registerCommentsPlugins() {
},
})

window.OCA.Activity.registerSidebarEntries(async ({ fileInfo, limit, offset }) => {
const { data: comments } = await getComments({ resourceType: 'files', resourceId: fileInfo.id }, { limit, offset })
logger.debug('Loaded comments', { fileInfo, comments })
window.OCA.Activity.registerSidebarEntries(async ({ node, limit, offset }: { node: INode, limit?: number, offset?: number }) => {
const { data: comments } = await getComments(
{ resourceType: 'files', resourceId: node.fileid },
{
limit,
offset: offset ?? 0,
},
)
logger.debug('Loaded comments', { node, comments })
const { default: CommentView } = await import('./views/ActivityCommentEntry.vue')
// @ts-expect-error Types are broken for Vue2
const CommentsViewObject = Vue.extend(CommentView)
Expand All @@ -62,7 +70,7 @@ export function registerCommentsPlugins() {
el: element,
propsData: {
comment,
resourceId: fileInfo.id,
resourceId: node.fileid,
reloadCallback: reload,
},
})
Expand Down
4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-tab.js.map

Large diffs are not rendered by default.

Loading