Add dialog to see who has read this message

You were previously relegated to looking at any avatars or a buggy
tooltip, but suffer no longer! If you tap on a message's read marker, a
dialog will pop up listing the users who have read it.

Uou can also view their profiles from here, etc.
This commit is contained in:
Joshua Goins
2026-01-09 18:25:11 -05:00
parent 71c84be4b4
commit e8da02be7d
6 changed files with 118 additions and 27 deletions

View File

@@ -7,8 +7,6 @@
#include <Quotient/roommember.h>
#define MAXMARKERS 5
using namespace Qt::StringLiterals;
ReadMarkerModel::ReadMarkerModel(const QString &eventId, NeoChatRoom *room)
@@ -85,13 +83,17 @@ QVariant ReadMarkerModel::data(const QModelIndex &index, int role) const
return member.color();
}
if (role == UserIdRole) {
return member.id();
}
return {};
}
int ReadMarkerModel::rowCount(const QModelIndex &parent) const
{
Q_UNUSED(parent)
return std::min(int(m_markerIds.size()), MAXMARKERS);
return m_markerIds.size();
}
QHash<int, QByteArray> ReadMarkerModel::roleNames() const
@@ -100,6 +102,7 @@ QHash<int, QByteArray> ReadMarkerModel::roleNames() const
{DisplayNameRole, "displayName"},
{AvatarUrlRole, "avatarUrl"},
{ColorRole, "memberColor"},
{UserIdRole, "userId"},
};
}
@@ -122,17 +125,4 @@ QString ReadMarkerModel::readMarkersString()
return readMarkersString;
}
QString ReadMarkerModel::excessReadMarkersString()
{
if (m_room == nullptr) {
return {};
}
if (m_markerIds.size() > MAXMARKERS) {
return u"+ "_s + QString::number(m_markerIds.size() - MAXMARKERS);
} else {
return QString();
}
}
#include "moc_readmarkermodel.cpp"

View File

@@ -26,13 +26,6 @@ class ReadMarkerModel : public QAbstractListModel
*/
Q_PROPERTY(QString readMarkersString READ readMarkersString NOTIFY reactionUpdated)
/**
* @brief Returns the number of excess user read markers for the event.
*
* This returns a string in the form "+ x" ready for use in the UI.
*/
Q_PROPERTY(QString excessReadMarkersString READ excessReadMarkersString NOTIFY reactionUpdated)
public:
/**
* @brief Defines the model roles.
@@ -41,12 +34,12 @@ public:
DisplayNameRole = Qt::DisplayRole, /**< The display name of the member in the room. */
AvatarUrlRole, /**< The avatar for the member in the room. */
ColorRole, /**< The color for the member. */
UserIdRole, /** The user ID for the member. */
};
explicit ReadMarkerModel(const QString &eventId, NeoChatRoom *room);
QString readMarkersString();
QString excessReadMarkersString();
/**
* @brief Get the given role value at the given index.