diff --git a/src/timeline/ReactionsModel.cpp b/src/timeline/ReactionsModel.cpp index f21b1c53a52c935678ec995b8e4058b195c8eb90..b686c750bd54336133e256fa6ab7fd237faf1dc8 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 a0a8580dd2a5e7059f66565df56247e138ff78d6..5f61cd424debc78e15e26fbb545482eb5bbaad74 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 0555d2ba41b8c790c2450c8807ca6aa2a1deb96d..5e57952ae90461762560f0021a287cc0d09f920d 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));