summary refs log tree commit diff
path: root/src/ui
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-10-23 23:58:53 +0200
committerNicolas Werner <nicolas.werner@hotmail.de>2023-10-23 23:58:53 +0200
commitfce026725e52b59a79e34dcfb70953173f3cd3be (patch)
tree57f5bc5ab630cd20846b0e590063c80208cbc12a /src/ui
parentprevent overscroll in roomlist and communities list (diff)
parentFix license lint... (diff)
downloadnheko-fce026725e52b59a79e34dcfb70953173f3cd3be.tar.xz
Merge branch 'ignore-users' of github.com:NepNep21/nheko into ignore-users
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/UserProfile.cpp36
-rw-r--r--src/ui/UserProfile.h3
2 files changed, 34 insertions, 5 deletions
diff --git a/src/ui/UserProfile.cpp b/src/ui/UserProfile.cpp

index 80def409..3b2375ad 100644 --- a/src/ui/UserProfile.cpp +++ b/src/ui/UserProfile.cpp
@@ -225,6 +225,38 @@ UserProfile::refreshDevices() } void +UserProfile::ignoredStatus(const QString &id, const bool ignore) +{ + auto old = TimelineViewManager::instance()->getIgnoredUsers(); + if (ignore) { + if (old.contains(id)) { + emit this->room()->ignoredUser(id, tr("Already ignored")); + return; + } + old.append(id); + } else { + old.removeOne(id); + } + + std::vector<mtx::events::account_data::IgnoredUser> content; + for (const QString &item : old) { + const mtx::events::account_data::IgnoredUser data{.id = item.toStdString()}; + content.push_back(data); + } + + const mtx::events::account_data::IgnoredUsers payload{.users{content}}; + + http::client()->put_account_data(payload, [this, id, ignore](mtx::http::RequestErr e) { + if (ignore) { + emit this->room()->ignoredUser( + id, e ? std::optional(QString::fromStdString(e->matrix_error.error)) : std::nullopt); + } else if (e) { + emit this->unignoredUserError(id, QString::fromStdString(e->matrix_error.error)); + } + }); +} + +void UserProfile::fetchDeviceList(const QString &userID) { if (!cache::client() || !cache::client()->isDatabaseReady()) @@ -345,10 +377,6 @@ UserProfile::banUser() ChatPage::instance()->banUser(roomid_, this->userid_, QLatin1String("")); } -// void ignoreUser(){ - -// } - void UserProfile::kickUser() { diff --git a/src/ui/UserProfile.h b/src/ui/UserProfile.h
index d8e06aa1..1affe8bd 100644 --- a/src/ui/UserProfile.h +++ b/src/ui/UserProfile.h
@@ -184,7 +184,7 @@ public: Q_INVOKABLE void refreshDevices(); Q_INVOKABLE void banUser(); Q_INVOKABLE void signOutDevice(const QString &deviceID); - // Q_INVOKABLE void ignoreUser(); + Q_INVOKABLE void ignoredStatus(const QString &id, const bool ignore); Q_INVOKABLE void kickUser(); Q_INVOKABLE void startChat(); Q_INVOKABLE void startChat(bool encryptionEnabled); @@ -201,6 +201,7 @@ signals: void displayError(const QString &errorMessage); void globalUsernameRetrieved(const QString &globalUser); void devicesChanged(); + void unignoredUserError(const QString &id, const QVariant &err); // internal void verificationStatiChanged();