diff --git a/src/channel.hpp b/src/channel.hpp
index 0342138f3..6a2433f6a 100644
--- a/src/channel.hpp
+++ b/src/channel.hpp
@@ -90,7 +90,7 @@ class IndirectChannel
std::shared_ptr data;
public:
- IndirectChannel(ChannelPtr channel, Channel::Type type = Channel::None)
+ IndirectChannel(ChannelPtr channel, Channel::Type type = Channel::Direct)
: data(new Data(channel, type))
{
}
diff --git a/src/singletons/accountmanager.cpp b/src/singletons/accountmanager.cpp
index 93be71b42..59e41f3fc 100644
--- a/src/singletons/accountmanager.cpp
+++ b/src/singletons/accountmanager.cpp
@@ -36,7 +36,7 @@ void AccountManager::load()
this->Twitch.currentUser = this->Twitch.anonymousUser;
}
- this->Twitch.userChanged.invoke();
+ // this->Twitch.userChanged.invoke();
}
} // namespace singletons
diff --git a/src/singletons/windowmanager.cpp b/src/singletons/windowmanager.cpp
index e91d5d43b..af4e59741 100644
--- a/src/singletons/windowmanager.cpp
+++ b/src/singletons/windowmanager.cpp
@@ -198,11 +198,7 @@ void WindowManager::initialize()
widgets::Split *split = new widgets::Split(tab);
QJsonObject split_obj = split_val.toObject();
- QJsonValue channelName_val = split_obj.value("channelName");
- if (channelName_val.isString()) {
- split->setChannel(providers::twitch::TwitchServer::getInstance().addChannel(
- channelName_val.toString()));
- }
+ split->setChannel(this->decodeChannel(split_obj));
tab->addToLayout(split, std::make_pair(colNr, 10000000));
}
@@ -270,7 +266,8 @@ void WindowManager::save()
for (widgets::Split *cell : cells) {
QJsonObject cell_obj;
- cell_obj.insert("channelName", cell->getChannel().get()->name);
+
+ this->encodeChannel(cell->getIndirectChannel(), cell_obj);
cells_arr.append(cell_obj);
}
@@ -297,6 +294,42 @@ void WindowManager::save()
file.flush();
}
+void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
+{
+ switch (channel.getType()) {
+ case Channel::Twitch: {
+ obj.insert("type", "twitch");
+ obj.insert("name", channel.get()->name);
+ } break;
+ case Channel::TwitchMentions: {
+ obj.insert("type", "mentions");
+ } break;
+ case Channel::TwitchWatching: {
+ obj.insert("type", "watching");
+ } break;
+ case Channel::TwitchWhispers: {
+ obj.insert("type", "whispers");
+ } break;
+ }
+}
+
+IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
+{
+ QString type = obj.value("type").toString();
+ if (type == "twitch") {
+ return providers::twitch::TwitchServer::getInstance().addChannel(
+ obj.value("name").toString());
+ } else if (type == "mentions") {
+ return providers::twitch::TwitchServer::getInstance().mentionsChannel;
+ } else if (type == "watching") {
+ return providers::twitch::TwitchServer::getInstance().watchingChannel;
+ } else if (type == "whispers") {
+ return providers::twitch::TwitchServer::getInstance().whispersChannel;
+ }
+
+ return Channel::getEmpty();
+}
+
void WindowManager::closeAll()
{
for (widgets::Window *window : windows) {
diff --git a/src/singletons/windowmanager.hpp b/src/singletons/windowmanager.hpp
index 349de4cc6..45af41e68 100644
--- a/src/singletons/windowmanager.hpp
+++ b/src/singletons/windowmanager.hpp
@@ -45,6 +45,9 @@ private:
widgets::Window *mainWindow = nullptr;
widgets::Window *selectedWindow = nullptr;
+
+ void encodeChannel(IndirectChannel channel, QJsonObject &obj);
+ IndirectChannel decodeChannel(const QJsonObject &obj);
};
} // namespace singletons
diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp
index 677a4dbee..1d1c35d33 100644
--- a/src/widgets/helper/splitheader.cpp
+++ b/src/widgets/helper/splitheader.cpp
@@ -154,12 +154,13 @@ void SplitHeader::scaleChangedEvent(float scale)
void SplitHeader::updateChannelText()
{
+ auto indirectChannel = this->split->getIndirectChannel();
auto channel = this->split->getChannel();
- const QString channelName = channel->name;
- if (channelName.isEmpty()) {
- this->titleLabel->setText("