Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(comments): Extend Vue before calling new on it #46643

Merged
merged 2 commits into from
Jul 25, 2024
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
25 changes: 15 additions & 10 deletions apps/comments/src/comments-activity-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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'

Expand All @@ -23,18 +23,19 @@
const pinia = createPinia()

if (!ActivityTabPluginView) {
const { default: ActivityCommmentAction } = await import('./views/ActivityCommentAction.vue')
ActivityTabPluginView = ActivityCommmentAction
const { default: ActivityCommentAction } = await import('./views/ActivityCommentAction.vue')
/** @ts-expect-error Types are broken for Vue2 */

Check warning on line 27 in apps/comments/src/comments-activity-tab.ts

View workflow job for this annotation

GitHub Actions / NPM lint

Invalid JSDoc tag name "ts-expect-error"
ActivityTabPluginView = Vue.extend(ActivityCommentAction)
}
ActivityTabPluginInstance = new ActivityTabPluginView({
el,
parent: context,
pinia,
propsData: {
reloadCallback: reload,
resourceId: fileInfo.id,
},
pinia,
})
ActivityTabPluginInstance.$mount(el)
logger.info('Comments plugin mounted in Activity sidebar action', { fileInfo })
},
unmount: () => {
Expand All @@ -49,23 +50,27 @@
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')
const CommentsViewObject = CommentView
/** @ts-expect-error Types are broken for Vue2 */

Check warning on line 53 in apps/comments/src/comments-activity-tab.ts

View workflow job for this annotation

GitHub Actions / NPM lint

Invalid JSDoc tag name "ts-expect-error"
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,
resourceId: fileInfo.id,
reloadCallback: reload,
},
})
this._CommentsViewInstance.$mount(element)
},
unmount() {
this._CommentsViewInstance.$destroy()
this._CommentsViewInstance?.$destroy()
},
}))
})
Expand Down
4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading