summary refs log tree commit diff
path: root/src/timeline2/TimelineModel.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2019-09-19 21:47:16 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2019-11-23 20:06:14 +0100
commit6c7e6b0e86ae78479b5f87b8440a8d10f99f14e0 (patch)
tree83cc96be09cb1031d3372445d0e909ffd15e05b7 /src/timeline2/TimelineModel.cpp
parentEnable read receipts action and sync read receipts from cache (diff)
downloadnheko-6c7e6b0e86ae78479b5f87b8440a8d10f99f14e0.tar.xz
Fix read indicator
Diffstat (limited to 'src/timeline2/TimelineModel.cpp')
-rw-r--r--src/timeline2/TimelineModel.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/timeline2/TimelineModel.cpp b/src/timeline2/TimelineModel.cpp

index d0daae25..1c9070b1 100644 --- a/src/timeline2/TimelineModel.cpp +++ b/src/timeline2/TimelineModel.cpp
@@ -268,6 +268,10 @@ TimelineModel::TimelineModel(QString room_id, QObject *parent) ev); events.remove(txn_id); 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)); }); } @@ -373,11 +377,17 @@ TimelineModel::data(const QModelIndex &index, int role) const case Id: return id; 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; else if (pending.contains(id)) 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; else return qml_mtx_events::Received; @@ -695,6 +705,7 @@ TimelineModel::indexToId(int index) const return eventOrder[index]; } +// Note: this will only be called for our messages void TimelineModel::markEventsAsRead(const std::vector<QString> &event_ids) {