Add edited flag to edited messages

Fix #206
This commit is contained in:
Carl Schwan
2020-12-28 18:11:35 +01:00
parent e6b97e3350
commit 4463e3e3f2
3 changed files with 11 additions and 1 deletions

View File

@@ -45,6 +45,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
roles[ShowAuthorRole] = "showAuthor";
roles[ShowSectionRole] = "showSection";
roles[ReactionRole] = "reaction";
roles[IsEditedRole] = "isEdited";
return roles;
}
@@ -453,6 +454,13 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
return EventStatus::Normal;
}
if (role == IsEditedRole) {
if (auto e = eventCast<const RoomMessageEvent>(&evt)) {
return !e->unsignedJson().isEmpty() && e->unsignedJson().contains("m.relations") && e->unsignedJson()["m.relations"].toObject().contains("m.replace");
}
return false;
}
if (role == EventIdRole) {
return !evt.id().isEmpty() ? evt.id() : evt.transactionId();
}