summary refs log tree commit diff
path: root/src/ui/RoomSettings.cpp
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2022-02-12 19:27:51 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2022-02-12 19:48:53 +0100
commit47b822604d81a6c603ce6c9e868456c8ccc2e18d (patch)
tree73f06796cff7941b9f0e7ab2b2a9e59054da0afa /src/ui/RoomSettings.cpp
parentHidden events: Make reusable read function (diff)
downloadnheko-47b822604d81a6c603ce6c9e868456c8ccc2e18d.tar.xz
Hidden events: Refactor slightly for reusability
Diffstat (limited to 'src/ui/RoomSettings.cpp')
-rw-r--r--src/ui/RoomSettings.cpp50
1 files changed, 0 insertions, 50 deletions
diff --git a/src/ui/RoomSettings.cpp b/src/ui/RoomSettings.cpp
index b7fb0887..43a11b7f 100644
--- a/src/ui/RoomSettings.cpp
+++ b/src/ui/RoomSettings.cpp
@@ -13,7 +13,6 @@
 #include <QStandardPaths>
 #include <QVBoxLayout>
 #include <mtx/events/event_type.hpp>
-#include <mtx/events/nheko_extensions/hidden_events.hpp>
 #include <mtx/responses/common.hpp>
 #include <mtx/responses/media.hpp>
 #include <mtxclient/http/client.hpp>
@@ -228,8 +227,6 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
         accessRules_ = 4;
     }
     emit accessJoinRulesChanged();
-
-    readHiddenEventsSettings(roomid_);
 }
 
 QString
@@ -641,50 +638,3 @@ RoomSettings::updateAvatar()
             });
       });
 }
-
-void
-RoomSettings::saveHiddenEventsSettings(const QSet<QString> &events, const QString &roomId)
-{
-    account_data::nheko_extensions::HiddenEvents hiddenEvents;
-    hiddenEvents.hidden_event_types = {
-      EventType::Reaction, EventType::CallCandidates, EventType::Unsupported};
-    for (const auto &event : events) {
-        hiddenEvents.hidden_event_types.emplace_back(getEventType(event.toStdString()));
-    }
-
-    if (!roomId.isEmpty()) {
-        const auto rid = roomId.toStdString();
-        http::client()->put_room_account_data(rid, hiddenEvents, [&rid](mtx::http::RequestErr e) {
-            if (e) {
-                nhlog::net()->error(
-                  "Failed to update room account data with hidden events in {}: {}", rid, *e);
-            }
-        });
-    } else {
-        http::client()->put_account_data(hiddenEvents, [](mtx::http::RequestErr e) {
-            if (e) {
-                nhlog::net()->error("Failed to update account data with hidden events: {}", *e);
-            }
-        });
-    }
-}
-
-bool
-RoomSettings::eventHidden(const QString event) const
-{
-    return hiddenEvents_.contains(event);
-}
-
-void
-RoomSettings::readHiddenEventsSettings(const QString &roomId)
-{
-    if (auto hiddenEvents = cache::client()->getAccountData(
-          mtx::events::EventType::NhekoHiddenEvents, roomId.toStdString())) {
-        if (auto tmp = std::get_if<mtx::events::EphemeralEvent<
-              mtx::events::account_data::nheko_extensions::HiddenEvents>>(&*hiddenEvents)) {
-            for (const auto event : tmp->content.hidden_event_types) {
-                hiddenEvents_.insert(mtx::events::to_string(event).data());
-            }
-        }
-    }
-}