Fix updating read receipt
- Find the last event that wasn't sent by us to update the marker to, instead of picking whichever is the most recent - Use the proper event ID instead of ID that could be a local echo - Wait for the current marker update request to complete before trying to send a new one
This commit is contained in:
parent
106bb3546f
commit
5402a332d2
|
@ -6,6 +6,7 @@ import QtQuick.Window 2.12
|
|||
import Clipboard 0.1
|
||||
import "../../.."
|
||||
import "../../../Base"
|
||||
import "../../../PythonBridge"
|
||||
import "../../../ShortcutBundles"
|
||||
|
||||
Rectangle {
|
||||
|
@ -238,6 +239,8 @@ Rectangle {
|
|||
property bool canLoad: true
|
||||
property bool loading: false
|
||||
|
||||
property Future updateMarkerFuture: null
|
||||
|
||||
property bool ownEventsOnLeft:
|
||||
window.settings.ownMessagesOnLeftAboveWidth < 0 ?
|
||||
false :
|
||||
|
@ -353,16 +356,28 @@ Rectangle {
|
|||
}
|
||||
|
||||
Timer {
|
||||
interval: window.settings.markRoomReadMsecDelay
|
||||
interval: Math.max(100, window.settings.markRoomReadMsecDelay)
|
||||
|
||||
running:
|
||||
! eventList.updateMarkerFuture &&
|
||||
(chat.roomInfo.unreads || chat.roomInfo.highlights) &&
|
||||
Qt.application.state === Qt.ApplicationActive &&
|
||||
(eventList.contentY + eventList.height) > -50
|
||||
|
||||
onTriggered: {
|
||||
const eventId = eventList.model.get(0).id
|
||||
py.callCoro("update_room_read_marker", [chat.roomId, eventId])
|
||||
for (let i = 0; i < eventList.model.count; i++) {
|
||||
const item = eventList.model.get(i)
|
||||
|
||||
if (item.sender !== chat.userId) {
|
||||
eventList.updateMarkerFuture = py.callCoro(
|
||||
"update_room_read_marker",
|
||||
[chat.roomId, item.event_id],
|
||||
() => { eventList.updateMarkerFuture = null },
|
||||
() => { eventList.updateMarkerFuture = null },
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user