summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/CommunitiesList.cpp10
-rw-r--r--src/UserSettingsPage.cpp9
-rw-r--r--src/UserSettingsPage.h3
3 files changed, 22 insertions, 0 deletions
diff --git a/src/CommunitiesList.cpp b/src/CommunitiesList.cpp
index 38d27864..cf0e7290 100644
--- a/src/CommunitiesList.cpp
+++ b/src/CommunitiesList.cpp
@@ -3,6 +3,7 @@
 #include "Logging.h"
 #include "MatrixClient.h"
 #include "Splitter.h"
+#include "UserSettingsPage.h"
 
 #include <mtx/responses/groups.hpp>
 #include <nlohmann/json.hpp>
@@ -125,9 +126,15 @@ CommunitiesList::setTagsForRoom(const QString &room_id, const std::vector<std::s
 void
 CommunitiesList::addCommunity(const std::string &group_id)
 {
+        auto hiddenTags = UserSettings::instance()->hiddenTags();
+
         const auto id = QString::fromStdString(group_id);
 
         CommunitiesListItem *list_item = new CommunitiesListItem(id, scrollArea_);
+
+        if (hiddenTags.contains(id))
+                list_item->setDisabled(true);
+
         communities_.emplace(id, QSharedPointer<CommunitiesListItem>(list_item));
         contentsLayout_->insertWidget(contentsLayout_->count() - 1, list_item);
 
@@ -142,6 +149,9 @@ CommunitiesList::addCommunity(const std::string &group_id)
                                 break;
                         }
                 }
+
+                auto hiddenTags = hiddenTagsAndCommunities();
+                UserSettings::instance()->setHiddenTags({hiddenTags.begin(), hiddenTags.end()});
         });
 
         if (group_id.empty() || group_id.front() != '+')
diff --git a/src/UserSettingsPage.cpp b/src/UserSettingsPage.cpp
index f90938c9..0e3bd667 100644
--- a/src/UserSettingsPage.cpp
+++ b/src/UserSettingsPage.cpp
@@ -81,6 +81,7 @@ UserSettings::load(std::optional<QString> profile)
         hasAlertOnNotification_  = settings.value("user/alert_on_notification", false).toBool();
         startInTray_             = settings.value("user/window/start_in_tray", false).toBool();
         groupView_               = settings.value("user/group_view", true).toBool();
+        hiddenTags_              = settings.value("user/hidden_tags", QStringList{}).toStringList();
         buttonsInTimeline_       = settings.value("user/timeline/buttons", true).toBool();
         timelineMaxWidth_        = settings.value("user/timeline/max_width", 0).toInt();
         messageHoverHighlight_ =
@@ -185,6 +186,13 @@ UserSettings::setGroupView(bool state)
 }
 
 void
+UserSettings::setHiddenTags(QStringList hiddenTags)
+{
+        hiddenTags_ = hiddenTags;
+        save();
+}
+
+void
 UserSettings::setMarkdown(bool state)
 {
         if (state == markdown_)
@@ -538,6 +546,7 @@ UserSettings::save()
         settings.setValue("minor_events", sortByImportance_);
         settings.setValue("read_receipts", readReceipts_);
         settings.setValue("group_view", groupView_);
+        settings.setValue("hidden_tags", hiddenTags_);
         settings.setValue("markdown_enabled", markdown_);
         settings.setValue("desktop_notifications", hasDesktopNotifications_);
         settings.setValue("alert_on_notification", hasAlertOnNotification_);
diff --git a/src/UserSettingsPage.h b/src/UserSettingsPage.h
index 6744d101..15da235b 100644
--- a/src/UserSettingsPage.h
+++ b/src/UserSettingsPage.h
@@ -144,6 +144,7 @@ public:
         void setAccessToken(QString accessToken);
         void setDeviceId(QString deviceId);
         void setHomeserver(QString homeserver);
+        void setHiddenTags(QStringList hiddenTags);
 
         QString theme() const { return !theme_.isEmpty() ? theme_ : defaultTheme_; }
         bool messageHoverHighlight() const { return messageHoverHighlight_; }
@@ -182,6 +183,7 @@ public:
         QString accessToken() const { return accessToken_; }
         QString deviceId() const { return deviceId_; }
         QString homeserver() const { return homeserver_; }
+        QStringList hiddenTags() const { return hiddenTags_; }
 
 signals:
         void groupViewStateChanged(bool state);
@@ -257,6 +259,7 @@ private:
         QString accessToken_;
         QString deviceId_;
         QString homeserver_;
+        QStringList hiddenTags_;
 
         static QSharedPointer<UserSettings> instance_;
 };