summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2020-05-06 11:28:24 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2020-05-06 11:28:24 +0200
commite045e3eb1cbb3785153ca7634f76ba80b9d16bb1 (patch)
treeff5d4432e30442b6224c5204c429b45d0f246054 /src
parentFix reaction count (diff)
downloadnheko-e045e3eb1cbb3785153ca7634f76ba80b9d16bb1.tar.xz
Show displayname on reactions
Diffstat (limited to 'src')
-rw-r--r--src/timeline/ReactionsModel.cpp11
-rw-r--r--src/timeline/ReactionsModel.h4
-rw-r--r--src/timeline/TimelineModel.cpp2
3 files changed, 11 insertions, 6 deletions
diff --git a/src/timeline/ReactionsModel.cpp b/src/timeline/ReactionsModel.cpp

index f21b1c53..b686c750 100644 --- a/src/timeline/ReactionsModel.cpp +++ b/src/timeline/ReactionsModel.cpp
@@ -1,9 +1,8 @@ #include "ReactionsModel.h" +#include <Cache.h> #include <MatrixClient.h> -#include "Logging.h" - QHash<int, QByteArray> ReactionsModel::roleNames() const { @@ -41,7 +40,8 @@ ReactionsModel::data(const QModelIndex &index, int role) const users += ", "; else first = false; - users += QString::fromStdString(reaction.sender); + users += + QString::fromStdString(cache::displayName(room_id_, reaction.sender)); } return users; } @@ -56,8 +56,11 @@ ReactionsModel::data(const QModelIndex &index, int role) const } void -ReactionsModel::addReaction(const mtx::events::RoomEvent<mtx::events::msg::Reaction> &reaction) +ReactionsModel::addReaction(const std::string &room_id, + const mtx::events::RoomEvent<mtx::events::msg::Reaction> &reaction) { + room_id_ = room_id; + int idx = 0; for (auto &storedReactions : reactions) { if (storedReactions.key == reaction.content.relates_to.key) { diff --git a/src/timeline/ReactionsModel.h b/src/timeline/ReactionsModel.h
index a0a8580d..5f61cd42 100644 --- a/src/timeline/ReactionsModel.h +++ b/src/timeline/ReactionsModel.h
@@ -26,7 +26,8 @@ public: QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override; public slots: - void addReaction(const mtx::events::RoomEvent<mtx::events::msg::Reaction> &reaction); + void addReaction(const std::string &room_id, + const mtx::events::RoomEvent<mtx::events::msg::Reaction> &reaction); void removeReaction(const mtx::events::RoomEvent<mtx::events::msg::Reaction> &reaction); private: @@ -35,5 +36,6 @@ private: std::string key; std::map<std::string, mtx::events::RoomEvent<mtx::events::msg::Reaction>> reactions; }; + std::string room_id_; std::vector<KeyReaction> reactions; }; diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 0555d2ba..5e57952a 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -619,7 +619,7 @@ TimelineModel::internalAddEvents( std::get_if<mtx::events::RoomEvent<mtx::events::msg::Reaction>>(&e)) { QString reactedTo = QString::fromStdString(reaction->content.relates_to.event_id); - reactions[reactedTo].addReaction(*reaction); + reactions[reactedTo].addReaction(room_id_.toStdString(), *reaction); int idx = idToIndex(reactedTo); if (idx >= 0) emit dataChanged(index(idx, 0), index(idx, 0));