Fix read indicator

This commit is contained in:
Nicolas Werner 2019-09-19 21:47:16 +02:00
parent d34067a257
commit 6c7e6b0e86
2 changed files with 15 additions and 4 deletions

View file

@ -9,13 +9,13 @@ Rectangle {
color: "transparent" color: "transparent"
width: 16 width: 16
height: 16 height: 16
ToolTip.visible: ma.containsMouse ToolTip.visible: ma.containsMouse && state != MtxEvent.Empty
ToolTip.text: switch (state) { ToolTip.text: switch (state) {
case MtxEvent.Failed: return qsTr("Failed") case MtxEvent.Failed: return qsTr("Failed")
case MtxEvent.Sent: return qsTr("Sent") case MtxEvent.Sent: return qsTr("Sent")
case MtxEvent.Received: return qsTr("Received") case MtxEvent.Received: return qsTr("Received")
case MtxEvent.Read: return qsTr("Read") case MtxEvent.Read: return qsTr("Read")
default: return qsTr("Empty") default: return ""
} }
MouseArea{ MouseArea{
id: ma id: ma

View file

@ -268,6 +268,10 @@ TimelineModel::TimelineModel(QString room_id, QObject *parent)
ev); ev);
events.remove(txn_id); events.remove(txn_id);
events.insert(event_id, ev); events.insert(event_id, ev);
// ask to be notified for read receipts
cache::client()->addPendingReceipt(room_id_, event_id);
emit dataChanged(index(idx, 0), index(idx, 0)); emit dataChanged(index(idx, 0), index(idx, 0));
}); });
} }
@ -373,11 +377,17 @@ TimelineModel::data(const QModelIndex &index, int role) const
case Id: case Id:
return id; return id;
case State: case State:
if (failed.contains(id)) // only show read receipts for messages not from us
if (boost::apply_visitor([](const auto &e) -> QString { return senderId(e); },
event)
.toStdString() != http::client()->user_id().to_string())
return qml_mtx_events::Empty;
else if (failed.contains(id))
return qml_mtx_events::Failed; return qml_mtx_events::Failed;
else if (pending.contains(id)) else if (pending.contains(id))
return qml_mtx_events::Sent; return qml_mtx_events::Sent;
else if (read.contains(id)) else if (read.contains(id) ||
cache::client()->readReceipts(id, room_id_).size() > 1)
return qml_mtx_events::Read; return qml_mtx_events::Read;
else else
return qml_mtx_events::Received; return qml_mtx_events::Received;
@ -695,6 +705,7 @@ TimelineModel::indexToId(int index) const
return eventOrder[index]; return eventOrder[index];
} }
// Note: this will only be called for our messages
void void
TimelineModel::markEventsAsRead(const std::vector<QString> &event_ids) TimelineModel::markEventsAsRead(const std::vector<QString> &event_ids)
{ {