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

[stable29] fix(comments): Fix issues thrown by comments sidebar tab code #44903

Merged
merged 2 commits into from
May 28, 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
3 changes: 3 additions & 0 deletions apps/comments/src/comments-tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ if (loadState('comments', 'activityEnabled', false) && OCA?.Activity?.registerSi
TabInstance = new OCA.Comments.View('files', {
// Better integration with vue parent component
parent: context,
propsData: {
resourceId: fileInfo.id,
},
})
// Only mount after we have all the info we need
await TabInstance.update(fileInfo.id)
Expand Down
18 changes: 12 additions & 6 deletions apps/comments/src/views/Comments.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
:resource-type="resourceType"
:editor="true"
:user-data="userData"
:resource-id="resourceId"
:resource-id="currentResourceId"
class="comments__writer"
@new="onNewComment" />

Expand All @@ -52,7 +52,7 @@
:auto-complete="autoComplete"
:resource-type="resourceType"
:message.sync="comment.props.message"
:resource-id="resourceId"
:resource-id="currentResourceId"
:user-data="genMentionsData(comment.props.mentions)"
class="comments__list"
@delete="onDelete" />
Expand Down Expand Up @@ -125,7 +125,7 @@ export default {
loading: false,
done: false,

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

Expand All @@ -145,13 +145,19 @@ export default {
},
},

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

methods: {
t,

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

this.logger.debug(`Processed ${comments.length} comments`, { comments })
Expand Down
8 changes: 4 additions & 4 deletions apps/files/src/views/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
@opened="handleOpened"
@closing="handleClosing"
@closed="handleClosed">
<template #subname>
<template v-if="fileInfo" #subname>
<NcIconSvgWrapper v-if="fileInfo.isFavourited"
:path="mdiStar"
:name="t('files', 'Favorite')"
Expand Down Expand Up @@ -222,7 +222,7 @@ export default {
* @return {string}
*/
size() {
return formatFileSize(this.fileInfo.size)
return formatFileSize(this.fileInfo?.size)
},

/**
Expand Down Expand Up @@ -334,7 +334,7 @@ export default {
},

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 this.getIconUrl(fileInfo)
Expand All @@ -348,7 +348,7 @@ export default {
* @return {string} Url to the icon for mimeType
*/
getIconUrl(fileInfo) {
const mimeType = fileInfo.mimetype || 'application/octet-stream'
const mimeType = fileInfo?.mimetype || 'application/octet-stream'
if (mimeType === 'httpd/unix-directory') {
// use default folder icon
if (fileInfo.mountType === 'shared' || fileInfo.mountType === 'shared-root') {
Expand Down
4 changes: 2 additions & 2 deletions dist/comments-comments-app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-app.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/comments-comments-tab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/comments-comments-tab.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/files-sidebar.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/files-sidebar.js.map

Large diffs are not rendered by default.

Loading