summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicolas Werner <nicolas.werner@hotmail.de>2023-11-27 22:44:29 +0100
committerNicolas Werner <nicolas.werner@hotmail.de>2023-11-27 22:44:44 +0100
commiteb2c87f060100d3a582284ab16a642c996ea2060 (patch)
tree4173b8a8c254ea632a7d89aeb43f679f06adb77a
parentMerge pull request #1622 from felixonmars/patch-1 (diff)
downloadnheko-eb2c87f060100d3a582284ab16a642c996ea2060.tar.xz
Unset hidden space when space is left
-rw-r--r--src/timeline/CommunitiesModel.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/timeline/CommunitiesModel.cpp b/src/timeline/CommunitiesModel.cpp
index e1018f38..3ba4e92b 100644
--- a/src/timeline/CommunitiesModel.cpp
+++ b/src/timeline/CommunitiesModel.cpp
@@ -556,6 +556,11 @@ CommunitiesModel::sync(const mtx::responses::Sync &sync_)
         (void)room;
         if (spaces_.count(QString::fromStdString(roomid)))
             tagsUpdated = true;
+        if (hiddenTagIds_.contains(QString::fromStdString("space:" + roomid))) {
+            hiddenTagIds_.removeAll(QString::fromStdString("space:" + roomid));
+            UserSettings::instance()->setHiddenTags(hiddenTagIds_);
+            tagsUpdated = true;
+        }
     }
     for (const auto &e : sync_.account_data.events) {
         if (auto event =
@@ -633,6 +638,12 @@ CommunitiesModel::toggleTagId(QString tagId)
         hiddenTagIds_.removeOne(tagId);
     else
         hiddenTagIds_.push_back(tagId);
+
+    // sanity check to remove stale spaces
+    hiddenTagIds_.removeIf([this](const QString &value) {
+        return value.startsWith("space:") && !spaces_.contains(value.mid(6));
+    });
+
     UserSettings::instance()->setHiddenTags(hiddenTagIds_);
 
     if (tagId.startsWith(QLatin1String("tag:"))) {