Persist hidden tags

pull/405/head
Nicolas Werner 4 years ago
parent fdb9d7ab40
commit 6ae1a5e8ad
  1. 10
      src/CommunitiesList.cpp
  2. 9
      src/UserSettingsPage.cpp
  3. 3
      src/UserSettingsPage.h

@ -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() != '+')

@ -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_ =
@ -184,6 +185,13 @@ UserSettings::setGroupView(bool state)
save();
}
void
UserSettings::setHiddenTags(QStringList hiddenTags)
{
hiddenTags_ = hiddenTags;
save();
}
void
UserSettings::setMarkdown(bool state)
{
@ -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_);

@ -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_;
};

Loading…
Cancel
Save