Skip to content

Commit 835d507

Browse files
authored
Merge pull request #57354 from nextcloud/fix/comments-node-api
fix(comments): adjust Activity integration for changed Node API
2 parents bd90e7c + 9e2058d commit 835d507

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

apps/comments/src/comments-activity-tab.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
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+
68
import moment from '@nextcloud/moment'
79
import { createPinia, PiniaVuePlugin } from 'pinia'
810
import Vue, { type ComponentPublicInstance } from 'vue'
@@ -19,7 +21,7 @@ let ActivityTabPluginInstance
1921
*/
2022
export 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
})

dist/comments-comments-tab.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/comments-comments-tab.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)