From 10b81ed45ec78e9b93b1ef069c1cb7b63963002c Mon Sep 17 00:00:00 2001 From: greta Date: Wed, 14 Aug 2024 13:40:58 +0200 Subject: [PATCH] stable28: fix comment deletion Signed-off-by: greta Signed-off-by: nextcloud-command --- apps/comments/src/comments-activity-tab.ts | 49 ++++++++--------- apps/comments/src/components/Comment.vue | 53 +++++++++---------- apps/comments/src/mixins/CommentMixin.js | 31 +++++------ .../comments/src/services/CommentsInstance.js | 32 ++++------- .../comments/src/store/deletedCommentLimbo.js | 28 ++++++++++ dist/7462-7462.js | 4 +- dist/7462-7462.js.map | 2 +- dist/comments-comments-app.js | 4 +- dist/comments-comments-app.js.LICENSE.txt | 28 +++------- dist/comments-comments-app.js.map | 2 +- dist/comments-comments-tab.js | 4 +- dist/comments-comments-tab.js.LICENSE.txt | 28 +++------- dist/comments-comments-tab.js.map | 2 +- dist/core-common.js | 4 +- dist/core-common.js.map | 2 +- dist/core-main.js | 4 +- dist/core-main.js.map | 2 +- dist/files-sidebar.js | 4 +- dist/files-sidebar.js.map | 2 +- dist/files_reminders-init.js | 4 +- dist/files_reminders-init.js.map | 2 +- dist/files_sharing-personal-settings.js | 4 +- dist/files_sharing-personal-settings.js.map | 2 +- .../settings-vue-settings-admin-delegation.js | 4 +- ...tings-vue-settings-admin-delegation.js.map | 2 +- 25 files changed, 135 insertions(+), 168 deletions(-) create mode 100644 apps/comments/src/store/deletedCommentLimbo.js diff --git a/apps/comments/src/comments-activity-tab.ts b/apps/comments/src/comments-activity-tab.ts index 0cb3bf70bbb54..f38484d25e77a 100644 --- a/apps/comments/src/comments-activity-tab.ts +++ b/apps/comments/src/comments-activity-tab.ts @@ -1,29 +1,16 @@ /** - * @copyright Copyright (c) 2023 Ferdinand Thiessen - * - * @author Ferdinand Thiessen - * - * @license AGPL-3.0-or-later - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - * + * SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ import moment from '@nextcloud/moment' -import Vue from 'vue' +import Vue, { type ComponentPublicInstance } from 'vue' import logger from './logger.js' import { getComments } from './services/GetComments.js' +import { PiniaVuePlugin, createPinia } from 'pinia' + +Vue.use(PiniaVuePlugin) + let ActivityTabPluginView let ActivityTabPluginInstance @@ -33,18 +20,22 @@ let ActivityTabPluginInstance export function registerCommentsPlugins() { window.OCA.Activity.registerSidebarAction({ mount: async (el, { context, fileInfo, reload }) => { + const pinia = createPinia() + if (!ActivityTabPluginView) { - const { default: ActivityCommmentAction } = await import('./views/ActivityCommentAction.vue') - ActivityTabPluginView = Vue.extend(ActivityCommmentAction) + const { default: ActivityCommentAction } = await import('./views/ActivityCommentAction.vue') + /** @ts-expect-error Types are broken for Vue2 */ + ActivityTabPluginView = Vue.extend(ActivityCommentAction) } ActivityTabPluginInstance = new ActivityTabPluginView({ + el, parent: context, + pinia, propsData: { reloadCallback: reload, resourceId: fileInfo.id, }, }) - ActivityTabPluginInstance.$mount(el) logger.info('Comments plugin mounted in Activity sidebar action', { fileInfo }) }, unmount: () => { @@ -59,12 +50,17 @@ export function registerCommentsPlugins() { const { data: comments } = await getComments({ resourceType: 'files', resourceId: fileInfo.id }, { limit, offset }) logger.debug('Loaded comments', { fileInfo, comments }) const { default: CommentView } = await import('./views/ActivityCommentEntry.vue') + /** @ts-expect-error Types are broken for Vue2 */ const CommentsViewObject = Vue.extend(CommentView) return comments.map((comment) => ({ - timestamp: moment(comment.props.creationDateTime).toDate().getTime(), - mount(element, { context, reload }) { + _CommentsViewInstance: undefined as ComponentPublicInstance | undefined, + + timestamp: moment(comment.props?.creationDateTime).toDate().getTime(), + + mount(element: HTMLElement, { context, reload }) { this._CommentsViewInstance = new CommentsViewObject({ + el: element, parent: context, propsData: { comment, @@ -72,10 +68,9 @@ export function registerCommentsPlugins() { reloadCallback: reload, }, }) - this._CommentsViewInstance.$mount(element) }, unmount() { - this._CommentsViewInstance.$destroy() + this._CommentsViewInstance?.$destroy() }, })) }) diff --git a/apps/comments/src/components/Comment.vue b/apps/comments/src/components/Comment.vue index 051815a0b9cdd..6a02bcd8c6a15 100644 --- a/apps/comments/src/components/Comment.vue +++ b/apps/comments/src/components/Comment.vue @@ -1,27 +1,10 @@ + - SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors + - SPDX-License-Identifier: AGPL-3.0-or-later +-->