Skip to content

Commit

Permalink
Expand upon test channels (#4655)
Browse files Browse the repository at this point in the history
Available test channels:

- `$$$` - Fill up scrollback (1000 messages), then add a new message every 500ms
- `$$$:e` - Add a new message every 500ms
- `$$$$` - Fill up scrollback (1000 messages), then add a new message every 250ms
- `$$$$:e` - Add a new message every 250ms
- `$$$$$` - Fill up scrollback (1000 messages), then add a new message every 100ms
- `$$$$$:e` - Add a new message every 100ms
- `$$$$$$` - Fill up scrollback (1000 messages), then add a new message every 50ms
- `$$$$$$:e` - Add a new message every 50ms
- `$$$$$$$` - Fill up scrollback (1000 messages), then add a new message every 25ms
- `$$$$$$$:e` - Add a new message every 25ms
  • Loading branch information
pajlada authored May 27, 2023
1 parent c6c884d commit 5ca7d38
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
- Dev: Added the ability to see & load custom themes from the Themes directory. No stable promises are made of this feature, changes might be made that breaks custom themes without notice. (#4570)
- Dev: Added test cases for emote and tab completion. (#4644)
- Dev: Fixed `clang-tidy-review` action not picking up dependencies. (#4648)
- Dev: Expanded upon `$$$` test channels. (#4655)

## 2.4.4

Expand Down
104 changes: 91 additions & 13 deletions src/providers/twitch/TwitchIrcServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,24 +274,102 @@ std::shared_ptr<Channel> TwitchIrcServer::getCustomChannel(
return this->liveChannel;
}

if (channelName == "$$$")
{
static auto channel =
std::make_shared<Channel>("$$$", chatterino::Channel::Type::Misc);
static auto getTimer = [&] {
static auto getTimer = [](ChannelPtr channel, int msBetweenMessages,
bool addInitialMessages) {
if (addInitialMessages)
{
for (auto i = 0; i < 1000; i++)
{
channel->addMessage(makeSystemMessage(QString::number(i + 1)));
}
}

auto timer = new QTimer;
QObject::connect(timer, &QTimer::timeout, [] {
channel->addMessage(
makeSystemMessage(QTime::currentTime().toString()));
});
timer->start(500);
return timer;
}();
auto *timer = new QTimer;
QObject::connect(timer, &QTimer::timeout, [channel] {
channel->addMessage(
makeSystemMessage(QTime::currentTime().toString()));
});
timer->start(msBetweenMessages);
return timer;
};

if (channelName == "$$$")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 500, true);

return channel;
}
if (channelName == "$$$:e")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 500, false);

return channel;
}
if (channelName == "$$$$")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 250, true);

return channel;
}
if (channelName == "$$$$:e")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 250, false);

return channel;
}
if (channelName == "$$$$$")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 100, true);

return channel;
}
if (channelName == "$$$$$:e")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 100, false);

return channel;
}
if (channelName == "$$$$$$")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 50, true);

return channel;
}
if (channelName == "$$$$$$:e")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 50, false);

return channel;
}
if (channelName == "$$$$$$$")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 25, true);

return channel;
}
if (channelName == "$$$$$$$:e")
{
static auto channel = std::make_shared<Channel>(
channelName, chatterino::Channel::Type::Misc);
getTimer(channel, 25, false);

return channel;
}
Expand Down
8 changes: 8 additions & 0 deletions src/singletons/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj)
}
}
break;
case Channel::Type::Misc: {
obj.insert("type", "misc");
obj.insert("name", channel.get()->getName());
}
}
}

Expand Down Expand Up @@ -676,6 +680,10 @@ IndirectChannel WindowManager::decodeChannel(const SplitDescriptor &descriptor)
return Irc::instance().getOrAddChannel(descriptor.server_,
descriptor.channelName_);
}
else if (descriptor.type_ == "misc")
{
return app->twitch->getChannelOrEmpty(descriptor.channelName_);
}

return Channel::getEmpty();
}
Expand Down

0 comments on commit 5ca7d38

Please sign in to comment.