Conversation
2e26c68 to
6824eda
Compare
6824eda to
b963f7b
Compare
skjnldsv
left a comment
There was a problem hiding this comment.
There seems to be much more than just the comments as read?
Why can't we just watch the Comments component and handle read on scroll/focus or something? I am not super fond of this API change for comments only? Or maybe there are other usages this æctive handler might have on other tabs?
|
The There are two ways then
diff --git a/apps/comments/src/services/CommentsInstance.js b/apps/comments/src/services/CommentsInstance.js
index f5263f35c3..4a9c90d220 100644
--- a/apps/comments/src/services/CommentsInstance.js
+++ b/apps/comments/src/services/CommentsInstance.js
@@ -24,6 +24,7 @@ import { getLoggerBuilder } from '@nextcloud/logger'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'
import CommentsApp from '../views/Comments'
import Vue from 'vue'
+import VueObserveVisibility from 'vue-observe-visibility'
const logger = getLoggerBuilder()
.setApp('comments')
@@ -61,6 +62,8 @@ export default class CommentInstance {
},
})
+ Vue.use(VueObserveVisibility)
+
// Init Comments component
const View = Vue.extend(CommentsApp)
return new View(options)
diff --git a/apps/comments/src/views/Comments.vue b/apps/comments/src/views/Comments.vue
index fbe81d23b9..65e77c8f54 100644
--- a/apps/comments/src/views/Comments.vue
+++ b/apps/comments/src/views/Comments.vue
@@ -21,7 +21,9 @@
-->
<template>
- <div class="comments" :class="{ 'icon-loading': isFirstLoading }">
+ <div class="comments"
+ :class="{ 'icon-loading': isFirstLoading }"
+ v-observe-visibility="onVisibilityChange">
<!-- Editor -->
<Comment v-bind="editorData"
:auto-complete="autoComplete"
@@ -127,6 +129,17 @@ export default {
},
methods: {
+ async onVisibilityChange(isVisible) {
+ if (isVisible) {
+ try {
+ await markCommentsAsRead(this.commentsType, this.ressourceId, new Date())
+ emit('comments:comments:read', { ressourceId: this.ressourceId })
+ } catch (e) {
+ showError(e.message || t('comments', 'Error marking comments as read'))
+ }
+ }
+ },
+
/**
* Update current ressourceId and fetch new data
*What do you think @skjnldsv? |
|
What do you think about the |
|
Sorry, I forgot t reply. Do we actually require to check for focus? |
I don't know, what is Talk doing to check if a message is read? Maybe we can reuse the logic? In any case I would choose what makes a consistent feeling. |
The The hacky way without the API addition would be to watch
Talk is invoking it on scroll, see https://github.com/nextcloud/spreed/blob/d9b7a3f53bb40fadc0295a52b4e0f52605e179f5/src/components/MessagesList/MessagesList.vue#L421-L424 -> https://github.com/nextcloud/spreed/blob/d9b7a3f53bb40fadc0295a52b4e0f52605e179f5/src/components/MessagesList/MessagesList.vue#L694-L757, which would only add complexity compared to the boolean check of marking comments as read on active The implementation of the |
|
Hello everyone, I was assigned maintainer of the comments app recently. @Pytal I think going forward with the visbilty observer is the best option! |
b963f7b to
ccfb772
Compare
ccfb772 to
78742b5
Compare
This comment was marked as outdated.
This comment was marked as outdated.
78742b5 to
006538b
Compare
|
/compile amend / |
e115125 to
c1679df
Compare
|
/rebase |
c1679df to
554c508
Compare
|
/compile |
Signed-off-by: Christopher Ng <chrng8@gmail.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
88cab51 to
94af306
Compare
|
/compile |
Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
miaulalala
left a comment
There was a problem hiding this comment.
LGTM didn't test but PROPPATCH looks fine
Fix #23877
Calls the existing DAV comments read handler
server/apps/dav/lib/Comments/EntityCollection.php
Lines 179 to 181 in 529d653
Run the following SQL query to observe updates to the database