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:
@@ -197,6 +197,22 @@ QQC2.Control {
|
||||
visible: root.currentRoom.mainCache.replyId.length > 0
|
||||
sourceComponent: replyPane
|
||||
}
|
||||
RowLayout {
|
||||
visible: replyLoader.visible && !root.currentRoom.mainCache.relationAuthorIsPresent
|
||||
spacing: Kirigami.Units.smallSpacing
|
||||
|
||||
Kirigami.Icon {
|
||||
source: "help-hint-symbolic"
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
|
||||
Layout.preferredWidth: Kirigami.Units.iconSizes.small
|
||||
Layout.preferredHeight: Kirigami.Units.iconSizes.small
|
||||
}
|
||||
QQC2.Label {
|
||||
text: i18nc("@info", "The user you're replying to has left the room, and can't be notified.")
|
||||
color: Kirigami.Theme.disabledTextColor
|
||||
}
|
||||
}
|
||||
Loader {
|
||||
id: attachLoader
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -99,6 +99,13 @@ class ChatBarCache : public QObject
|
||||
*/
|
||||
Q_PROPERTY(Quotient::RoomMember relationAuthor READ relationAuthor NOTIFY relationIdChanged)
|
||||
|
||||
/**
|
||||
* @brief If the author for the message being replied to is still present in the room.
|
||||
*
|
||||
* @sa Quotient::RoomMember
|
||||
*/
|
||||
Q_PROPERTY(bool relationAuthorIsPresent READ relationAuthorIsPresent NOTIFY relationAuthorIsPresentChanged)
|
||||
|
||||
/**
|
||||
* @brief The content of the related message.
|
||||
*
|
||||
@@ -153,6 +160,7 @@ public:
|
||||
void setEditId(const QString &editId);
|
||||
|
||||
Quotient::RoomMember relationAuthor() const;
|
||||
bool relationAuthorIsPresent() const;
|
||||
|
||||
QString relationMessage() const;
|
||||
|
||||
@@ -196,6 +204,7 @@ Q_SIGNALS:
|
||||
void threadIdChanged(const QString &oldThreadId, const QString &newThreadId);
|
||||
void attachmentPathChanged();
|
||||
void mentionAdded(const QString &mention);
|
||||
void relationAuthorIsPresentChanged();
|
||||
|
||||
private:
|
||||
QString m_text = QString();
|
||||
|
||||
Reference in New Issue
Block a user