Procházet zdrojové kódy

fix(comments): Fix issues thrown by comments sidebar tab code

When the comments tab is used instead of the merged activity+comments, then some issues are throws due to prop altering and duplicated names (resourceId as prop and data).

This is fixed as well as some other vue related errors in the sidebar

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
pull/44868/head
Ferdinand Thiessen před 1 měsícem
rodič
revize
6c9ca8b025
Žádný účet není propojen s e-mailovou adresou tvůrce revize

+ 3
- 0
apps/comments/src/comments-tab.js Zobrazit soubor

TabInstance = new OCA.Comments.View('files', { TabInstance = new OCA.Comments.View('files', {
// Better integration with vue parent component // Better integration with vue parent component
parent: context, parent: context,
propsData: {
resourceId: fileInfo.id,
},
}) })
// Only mount after we have all the info we need // Only mount after we have all the info we need
await TabInstance.update(fileInfo.id) await TabInstance.update(fileInfo.id)

+ 14
- 8
apps/comments/src/views/Comments.vue Zobrazit soubor

:resource-type="resourceType" :resource-type="resourceType"
:editor="true" :editor="true"
:user-data="userData" :user-data="userData"
:resource-id="resourceId"
:resource-id="currentResourceId"
class="comments__writer" class="comments__writer"
@new="onNewComment" /> @new="onNewComment" />


:auto-complete="autoComplete" :auto-complete="autoComplete"
:resource-type="resourceType" :resource-type="resourceType"
:message.sync="comment.props.message" :message.sync="comment.props.message"
:resource-id="resourceId"
:resource-id="currentResourceId"
:user-data="genMentionsData(comment.props.mentions)" :user-data="genMentionsData(comment.props.mentions)"
class="comments__list" class="comments__list"
@delete="onDelete" /> @delete="onDelete" />
<script> <script>
import { showError } from '@nextcloud/dialogs' import { showError } from '@nextcloud/dialogs'
import { translate as t } from '@nextcloud/l10n' import { translate as t } from '@nextcloud/l10n'
import { vElementVisibility } from '@vueuse/components'
import { vElementVisibility as elementVisibility } from '@vueuse/components'


import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js' import NcEmptyContent from '@nextcloud/vue/dist/Components/NcEmptyContent.js'
import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import NcButton from '@nextcloud/vue/dist/Components/NcButton.js'
}, },


directives: { directives: {
vElementVisibility,
elementVisibility,
}, },


mixins: [CommentView], mixins: [CommentView],
loading: false, loading: false,
done: false, done: false,


resourceId: null,
currentResourceId: this.resourceId,
offset: 0, offset: 0,
comments: [], comments: [],


}, },
}, },


watch: {
resourceId() {
this.currentResourceId = this.resourceId
},
},

methods: { methods: {
t, t,


async onVisibilityChange(isVisible) { async onVisibilityChange(isVisible) {
if (isVisible) { if (isVisible) {
try { try {
await markCommentsAsRead(this.resourceType, this.resourceId, new Date())
await markCommentsAsRead(this.resourceType, this.currentResourceId, new Date())
} catch (e) { } catch (e) {
showError(e.message || t('comments', 'Failed to mark comments as read')) showError(e.message || t('comments', 'Failed to mark comments as read'))
} }
* @param {number} resourceId the current resourceId (fileId...) * @param {number} resourceId the current resourceId (fileId...)
*/ */
async update(resourceId) { async update(resourceId) {
this.resourceId = resourceId
this.currentResourceId = resourceId
this.resetState() this.resetState()
this.getComments() this.getComments()
}, },
// Fetch comments // Fetch comments
const { data: comments } = await request({ const { data: comments } = await request({
resourceType: this.resourceType, resourceType: this.resourceType,
resourceId: this.resourceId,
resourceId: this.currentResourceId,
}, { offset: this.offset }) || { data: [] } }, { offset: this.offset }) || { data: [] }


this.logger.debug(`Processed ${comments.length} comments`, { comments }) this.logger.debug(`Processed ${comments.length} comments`, { comments })

+ 4
- 4
apps/files/src/views/Sidebar.vue Zobrazit soubor

@opened="handleOpened" @opened="handleOpened"
@closing="handleClosing" @closing="handleClosing"
@closed="handleClosed"> @closed="handleClosed">
<template #subname>
<template v-if="fileInfo" #subname>
<NcIconSvgWrapper v-if="fileInfo.isFavourited" <NcIconSvgWrapper v-if="fileInfo.isFavourited"
:path="mdiStar" :path="mdiStar"
:name="t('files', 'Favorite')" :name="t('files', 'Favorite')"
* @return {string} * @return {string}
*/ */
size() { size() {
return formatFileSize(this.fileInfo.size)
return formatFileSize(this.fileInfo?.size)
}, },


/** /**
}, },


getPreviewIfAny(fileInfo) { getPreviewIfAny(fileInfo) {
if (fileInfo.hasPreview && !this.isFullScreen) {
if (fileInfo?.hasPreview && !this.isFullScreen) {
return generateUrl(`/core/preview?fileId=${fileInfo.id}&x=${screen.width}&y=${screen.height}&a=true`) return generateUrl(`/core/preview?fileId=${fileInfo.id}&x=${screen.width}&y=${screen.height}&a=true`)
} }
return this.getIconUrl(fileInfo) return this.getIconUrl(fileInfo)
* @return {string} Url to the icon for mimeType * @return {string} Url to the icon for mimeType
*/ */
getIconUrl(fileInfo) { getIconUrl(fileInfo) {
const mimeType = fileInfo.mimetype || 'application/octet-stream'
const mimeType = fileInfo?.mimetype || 'application/octet-stream'
if (mimeType === 'httpd/unix-directory') { if (mimeType === 'httpd/unix-directory') {
// use default folder icon // use default folder icon
if (fileInfo.mountType === 'shared' || fileInfo.mountType === 'shared-root') { if (fileInfo.mountType === 'shared' || fileInfo.mountType === 'shared-root') {

Načítá se…
Zrušit
Uložit