mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Fix messages being immediately read again
This commit is contained in:
parent
692c6119b4
commit
a942ae9b93
2 changed files with 19 additions and 5 deletions
|
@ -960,9 +960,15 @@ Cache::saveState(const mtx::responses::Sync &res)
|
||||||
for (const auto &room : res.rooms.join) {
|
for (const auto &room : res.rooms.join) {
|
||||||
if (!room.second.ephemeral.receipts.empty()) {
|
if (!room.second.ephemeral.receipts.empty()) {
|
||||||
std::vector<QString> receipts;
|
std::vector<QString> receipts;
|
||||||
for (const auto &receipt : room.second.ephemeral.receipts)
|
for (const auto &receipt : room.second.ephemeral.receipts) {
|
||||||
if (receipt.first != user_id)
|
for (const auto &receiptUsersTs : receipt.second) {
|
||||||
receipts.push_back(QString::fromStdString(receipt.first));
|
if (receiptUsersTs.first != user_id) {
|
||||||
|
receipts.push_back(
|
||||||
|
QString::fromStdString(receipt.first));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!receipts.empty())
|
if (!receipts.empty())
|
||||||
emit newReadReceipts(QString::fromStdString(room.first), receipts);
|
emit newReadReceipts(QString::fromStdString(room.first), receipts);
|
||||||
}
|
}
|
||||||
|
|
|
@ -321,16 +321,24 @@ TimelineModel::data(const QString &id, int role) const
|
||||||
}
|
}
|
||||||
case Id:
|
case Id:
|
||||||
return id;
|
return id;
|
||||||
case State:
|
case State: {
|
||||||
|
auto containsOthers = [](const auto &vec) {
|
||||||
|
for (const auto &e : vec)
|
||||||
|
if (e.second != http::client()->user_id().to_string())
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
// only show read receipts for messages not from us
|
// only show read receipts for messages not from us
|
||||||
if (acc::sender(event) != http::client()->user_id().to_string())
|
if (acc::sender(event) != http::client()->user_id().to_string())
|
||||||
return qml_mtx_events::Empty;
|
return qml_mtx_events::Empty;
|
||||||
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) || cache::readReceipts(id, room_id_).size() > 1)
|
else if (read.contains(id) || containsOthers(cache::readReceipts(id, room_id_)))
|
||||||
return qml_mtx_events::Read;
|
return qml_mtx_events::Read;
|
||||||
else
|
else
|
||||||
return qml_mtx_events::Received;
|
return qml_mtx_events::Received;
|
||||||
|
}
|
||||||
case IsEncrypted: {
|
case IsEncrypted: {
|
||||||
return std::holds_alternative<
|
return std::holds_alternative<
|
||||||
mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(events[id]);
|
mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(events[id]);
|
||||||
|
|
Loading…
Reference in a new issue