diff --git a/src/controllers/moderationactions/ModerationActionModel.hpp b/src/controllers/moderationactions/ModerationActionModel.hpp index e9f372361..e13b3b27b 100644 --- a/src/controllers/moderationactions/ModerationActionModel.hpp +++ b/src/controllers/moderationactions/ModerationActionModel.hpp @@ -7,8 +7,6 @@ namespace chatterino { -class ModerationActions; - class ModerationActionModel : public SignalVectorModel { public: @@ -25,8 +23,6 @@ protected: std::vector &row) override; friend class HighlightController; - - friend class ModerationActions; }; } // namespace chatterino diff --git a/src/controllers/moderationactions/ModerationActions.cpp b/src/controllers/moderationactions/ModerationActions.cpp index 5d2ed9dc1..6215c81b8 100644 --- a/src/controllers/moderationactions/ModerationActions.cpp +++ b/src/controllers/moderationactions/ModerationActions.cpp @@ -2,41 +2,18 @@ #include "Application.hpp" #include "controllers/moderationactions/ModerationActionModel.hpp" -#include "singletons/Settings.hpp" +#include "util/PersistSignalVector.hpp" #include namespace chatterino { -ModerationActions::ModerationActions() -{ -} - void ModerationActions::initialize(Settings &settings, Paths &paths) { assert(!this->initialized_); this->initialized_ = true; - this->setting_ = - std::make_unique>>( - "/moderation/actions"); - - for (auto &val : this->setting_->getValue()) - { - this->items.insert(val); - } - - this->items.delayedItemsChanged.connect([this] { // - this->setting_->setValue(this->items.raw()); - }); -} - -ModerationActionModel *ModerationActions::createModel(QObject *parent) -{ - ModerationActionModel *model = new ModerationActionModel(parent); - model->initialize(&this->items); - - return model; + persist(this->items, "/moderation/actions"); } } // namespace chatterino diff --git a/src/controllers/moderationactions/ModerationActions.hpp b/src/controllers/moderationactions/ModerationActions.hpp index 7388019ba..8e6a4ded8 100644 --- a/src/controllers/moderationactions/ModerationActions.hpp +++ b/src/controllers/moderationactions/ModerationActions.hpp @@ -1,9 +1,7 @@ #pragma once -#include "common/Singleton.hpp" - -#include "common/ChatterinoSetting.hpp" #include "common/SignalVector.hpp" +#include "common/Singleton.hpp" #include "controllers/moderationactions/ModerationAction.hpp" namespace chatterino { @@ -11,21 +9,14 @@ namespace chatterino { class Settings; class Paths; -class ModerationActionModel; - class ModerationActions final : public Singleton { public: - ModerationActions(); - virtual void initialize(Settings &settings, Paths &paths) override; SignalVector items; - ModerationActionModel *createModel(QObject *parent); - private: - std::unique_ptr>> setting_; bool initialized_ = false; }; diff --git a/src/widgets/settingspages/ModerationPage.cpp b/src/widgets/settingspages/ModerationPage.cpp index 87e3a5e5d..8b1754d86 100644 --- a/src/widgets/settingspages/ModerationPage.cpp +++ b/src/widgets/settingspages/ModerationPage.cpp @@ -174,7 +174,8 @@ ModerationPage::ModerationPage() EditableModelView *view = modMode .emplace( - app->moderationActions->createModel(nullptr)) + (new ModerationActionModel(nullptr)) + ->initialized(&app->moderationActions->items)) .getElement(); view->setTitles({"Actions"});