Remind the user if they're trying to reply to someone who has left

This happens semi-frequently to me and others - we reply to a user who
has left the room. Sometimes this is useful (for example, bringing up a
previous topic) but in most cases this is accidental, and almost
guaranteed to happen if you turned off join/leave events.

So I added a reminder when replying - which manifests as a small label
in the chatbar - that the user has left and can't be notified of your
reply.
This commit is contained in:
Joshua Goins
2025-08-04 16:38:38 -04:00
parent 6822a1ef08
commit 93b6c53c82
5 changed files with 91 additions and 0 deletions

View File

@@ -15,6 +15,18 @@ using namespace Qt::StringLiterals;
ChatBarCache::ChatBarCache(QObject *parent)
: QObject(parent)
{
if (parent == nullptr) {
qWarning() << "ChatBarCache created with no parent, a NeoChatRoom must be set as the parent on creation.";
return;
}
auto room = dynamic_cast<NeoChatRoom *>(parent);
if (room == nullptr) {
qWarning() << "ChatBarCache created with incorrect parent, a NeoChatRoom must be set as the parent on creation.";
return;
}
connect(room, &NeoChatRoom::memberLeft, this, &ChatBarCache::relationAuthorIsPresentChanged);
connect(room, &NeoChatRoom::memberJoined, this, &ChatBarCache::relationAuthorIsPresentChanged);
connect(this, &ChatBarCache::relationIdChanged, this, &ChatBarCache::relationAuthorIsPresentChanged);
}
QString ChatBarCache::text() const
@@ -137,6 +149,11 @@ Quotient::RoomMember ChatBarCache::relationAuthor() const
return room->member((*room->findInTimeline(m_relationId))->senderId());
}
bool ChatBarCache::relationAuthorIsPresent() const
{
return relationAuthor().membershipState() == Quotient::Membership::Join;
}
QString ChatBarCache::relationMessage() const
{
if (parent() == nullptr) {