fix(comments): properly handle opening the sidebar when Activity integration is used

When the activity integration is used we need to open the `activity` tab
not the comments tab.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2026-02-12 17:17:25 +01:00
parent b80816dfb7
commit cd15bb0679
No known key found for this signature in database
GPG key ID: 7E849AE05218500F
3 changed files with 24 additions and 4 deletions

View file

@ -9,6 +9,7 @@ import CommentProcessingSvg from '@mdi/svg/svg/comment-processing.svg?raw'
import { getSidebar } from '@nextcloud/files'
import { n, t } from '@nextcloud/l10n'
import logger from '../logger.js'
import { isUsingActivityIntegration } from '../utils/activity.js'
export const action: IFileAction = {
id: 'comments-unread',
@ -38,7 +39,13 @@ export const action: IFileAction = {
try {
const sidebar = getSidebar()
sidebar.open(nodes[0], 'comments')
const sidebarTabId = isUsingActivityIntegration() ? 'activity' : 'comments'
if (sidebar.isOpen && sidebar.node?.source === nodes[0].source) {
logger.debug('Sidebar already open for this node, just activating comments tab')
sidebar.setActiveTab(sidebarTabId)
return null
}
sidebar.open(nodes[0], sidebarTabId)
return null
} catch (error) {
logger.error('Error while opening sidebar', { error })

View file

@ -1,4 +1,4 @@
/**
/*!
* SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
@ -6,18 +6,18 @@
import MessageReplyText from '@mdi/svg/svg/message-reply-text.svg?raw'
import { getCSPNonce } from '@nextcloud/auth'
import { registerSidebarTab } from '@nextcloud/files'
import { loadState } from '@nextcloud/initial-state'
import { t } from '@nextcloud/l10n'
import wrap from '@vue/web-component-wrapper'
import { createPinia, PiniaVuePlugin } from 'pinia'
import Vue from 'vue'
import { registerCommentsPlugins } from './comments-activity-tab.ts'
import { isUsingActivityIntegration } from './utils/activity.ts'
__webpack_nonce__ = getCSPNonce()
const tagName = 'comments_files-sidebar-tab'
if (loadState('comments', 'activityEnabled', false) && OCA?.Activity?.registerSidebarAction !== undefined) {
if (isUsingActivityIntegration()) {
// Do not mount own tab but mount into activity
window.addEventListener('DOMContentLoaded', function() {
registerCommentsPlugins()

View file

@ -0,0 +1,13 @@
/*!
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import { loadState } from '@nextcloud/initial-state'
/**
* Check if the comments app is using the Activity app integration for the sidebar.
*/
export function isUsingActivityIntegration() {
return loadState('comments', 'activityEnabled', false) && window.OCA?.Activity?.registerSidebarAction !== undefined
}