From 943f6c762c551e95a5bbf2870b2996b05234a5e3 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Wed, 21 Feb 2024 20:41:56 +0100 Subject: [PATCH] Fix (un)ignoring unknown users --- src/models/actionsmodel.cpp | 26 ++++++++------------------ 1 file changed, 8 insertions(+), 18 deletions(-) diff --git a/src/models/actionsmodel.cpp b/src/models/actionsmodel.cpp index eeb1ab85f..e59106e80 100644 --- a/src/models/actionsmodel.cpp +++ b/src/models/actionsmodel.cpp @@ -354,17 +354,12 @@ QList actions{ Q_EMIT room->showMessage(NeoChatRoom::Error, i18nc("'' does not look like a matrix id.", "'%1' does not look like a matrix id.", text)); return QString(); } - auto user = room->connection()->users()[text]; - if (room->connection()->ignoredUsers().contains(user->id())) { + if (room->connection()->ignoredUsers().contains(text)) { Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc(" is already ignored.", "%1 is already ignored.", text)); return QString(); } - if (user) { - room->connection()->addToIgnoredUsers(user); - Q_EMIT room->showMessage(NeoChatRoom::Positive, i18nc(" is now ignored", "%1 is now ignored.", text)); - } else { - Q_EMIT room->showMessage(NeoChatRoom::Error, i18nc(" is not a known user", "%1 is not a known user.", text)); - } + room->connection()->addToIgnoredUsers(room->connection()->user(text)); + Q_EMIT room->showMessage(NeoChatRoom::Positive, i18nc(" is now ignored", "%1 is now ignored.", text)); return QString(); }, false, @@ -382,17 +377,12 @@ QList actions{ Q_EMIT room->showMessage(NeoChatRoom::Error, i18nc("'' does not look like a matrix id.", "'%1' does not look like a matrix id.", text)); return QString(); } - auto user = room->connection()->users()[text]; - if (user) { - if (!room->connection()->ignoredUsers().contains(user->id())) { - Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc(" is not ignored.", "%1 is not ignored.", text)); - return QString(); - } - room->connection()->removeFromIgnoredUsers(user); - Q_EMIT room->showMessage(NeoChatRoom::Positive, i18nc(" is no longer ignored.", "%1 is no longer ignored.", text)); - } else { - Q_EMIT room->showMessage(NeoChatRoom::Error, i18nc(" is not a known user", "%1 is not a known user.", text)); + if (!room->connection()->ignoredUsers().contains(text)) { + Q_EMIT room->showMessage(NeoChatRoom::Info, i18nc(" is not ignored.", "%1 is not ignored.", text)); + return QString(); } + room->connection()->removeFromIgnoredUsers(room->connection()->user(text)); + Q_EMIT room->showMessage(NeoChatRoom::Positive, i18nc(" is no longer ignored.", "%1 is no longer ignored.", text)); return QString(); }, false,