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:
Vincent Petry 2021-03-01 12:34:09 +01:00
Родитель 3c6d5bc561
Коммит b99adb66bc
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E055D6A4D513575C
3 изменённых файлов: 11 добавлений и 13 удалений

Просмотреть файл

@ -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)
},
}