Show displayname on reactions

pull/192/head
Nicolas Werner 5 years ago
parent 8348a6c35d
commit e045e3eb1c
  1. 11
      src/timeline/ReactionsModel.cpp
  2. 4
      src/timeline/ReactionsModel.h
  3. 2
      src/timeline/TimelineModel.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) {

@ -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;
};

@ -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));

Loading…
Cancel
Save