saving irc splits now

This commit is contained in:
fourtf 2019-09-11 00:10:49 +02:00
parent c4d0efacff
commit 2a8c5e654f
2 changed files with 22 additions and 2 deletions

View file

@ -158,14 +158,15 @@ Irc &Irc::getInstance()
int Irc::uniqueId()
{
/// XXX: also check for channels
int i = this->currentId_ + 1;
auto it = this->servers_.find(i);
auto it2 = this->abandonedChannels_.find(i);
while (it != this->servers_.end())
while (it != this->servers_.end() || it2 != this->abandonedChannels_.end())
{
i++;
it = this->servers_.find(i);
it2 = this->abandonedChannels_.find(i);
}
return (this->currentId_ = i);

View file

@ -4,6 +4,9 @@
#include "debug/AssertInGuiThread.hpp"
#include "debug/Log.hpp"
#include "messages/MessageElement.hpp"
#include "providers/irc/Irc2.hpp"
#include "providers/irc/IrcChannel2.hpp"
#include "providers/irc/IrcServer.hpp"
#include "providers/twitch/TwitchServer.hpp"
#include "singletons/Fonts.hpp"
#include "singletons/Paths.hpp"
@ -612,6 +615,17 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
obj.insert("type", "whispers");
}
break;
case Channel::Type::Irc:
{
if (auto ircChannel =
dynamic_cast<IrcChannel *>(channel.get().get()))
{
obj.insert("type", "irc");
obj.insert("server", ircChannel->server()->id());
obj.insert("channel", ircChannel->getName());
}
}
break;
}
}
@ -639,6 +653,11 @@ IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
{
return app->twitch.server->whispersChannel;
}
else if (type == "irc")
{
return Irc::getInstance().getOrAddChannel(
obj.value("server").toInt(-1), obj.value("channel").toString());
}
return Channel::getEmpty();
}