зеркало из https://github.com/nextcloud/spreed.git
Tweak read marker behavior
When no scrolling is possible, add delay before clearing. Small related code cleanup. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
This commit is contained in:
Родитель
3c6d5bc561
Коммит
b99adb66bc
|
@ -414,8 +414,11 @@ export default {
|
|||
|
||||
// if no scrollbars, clear read marker directly as scrolling is not possible for the user to clear it
|
||||
// also clear in case lastReadMessage is zero which is due to an older bug
|
||||
if (this.conversation.lastReadMessage === 0 || (this.isWindowVisible && document.hasFocus() && this.scroller.scrollHeight <= this.scroller.offsetHeight)) {
|
||||
this.$store.dispatch('clearLastReadMessage', { token: this.token })
|
||||
if (this.conversation.lastReadMessage === 0
|
||||
|| (this.isWindowVisible && document.hasFocus() && this.scroller.scrollHeight <= this.scroller.offsetHeight)
|
||||
) {
|
||||
// clear after a delay, unless scrolling can resume in-between
|
||||
this.debounceUpdateReadMarkerAfterScroll()
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -752,7 +755,9 @@ export default {
|
|||
}
|
||||
|
||||
// if we're at bottom of the chat and focussed, then simply clear the marker
|
||||
if (this.isSticky && this.isWindowVisible && document.hasFocus()) {
|
||||
if (this.conversation.lastReadMessage === 0
|
||||
|| (this.isSticky && this.isWindowVisible && document.hasFocus())
|
||||
) {
|
||||
this.$store.dispatch('clearLastReadMessage', { token: this.token })
|
||||
return
|
||||
}
|
||||
|
|
|
@ -147,14 +147,9 @@ const postRichObjectToConversation = async function(token, { objectType, objectI
|
|||
* @param {int} lastReadMessage id of the last read message to set
|
||||
*/
|
||||
const updateLastReadMessage = async function(token, lastReadMessage) {
|
||||
try {
|
||||
const response = await axios.post(generateOcsUrl('apps/spreed/api/v1', 2) + `chat/${token}/read`, {
|
||||
lastReadMessage,
|
||||
})
|
||||
return response
|
||||
} catch (error) {
|
||||
console.error(`Error while updating the last read message to {lastReadMessage}`, error)
|
||||
}
|
||||
return axios.post(generateOcsUrl('apps/spreed/api/v1', 2) + `chat/${token}/read`, {
|
||||
lastReadMessage,
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
|
|
|
@ -344,8 +344,6 @@ const actions = {
|
|||
// optimistic early commit to avoid indicator flickering
|
||||
context.commit('updateConversationLastReadMessage', { token, lastReadMessage: id })
|
||||
await updateLastReadMessage(token, id)
|
||||
|
||||
// TODO: update unread counters if possible (otherwise user needs to wait for conversation list refresh)
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче