mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Show displayname on reactions
This commit is contained in:
parent
8348a6c35d
commit
e045e3eb1c
3 changed files with 11 additions and 6 deletions
|
@ -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…
Reference in a new issue