mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Add function for getting a Twitch Channel from a server by its ID
This commit is contained in:
parent
3dad7e778a
commit
d62e45d9dd
2 changed files with 27 additions and 0 deletions
|
@ -169,6 +169,31 @@ void TwitchServer::forEachChannelAndSpecialChannels(std::function<void(ChannelPt
|
||||||
func(this->mentionsChannel);
|
func(this->mentionsChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::shared_ptr<Channel> TwitchServer::getChannelOrEmptyByID(const QString &channelID)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
std::lock_guard<std::mutex> lock(this->channelMutex);
|
||||||
|
|
||||||
|
for (const auto &weakChannel : this->channels) {
|
||||||
|
auto channel = weakChannel.lock();
|
||||||
|
if (!channel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto twitchChannel = std::dynamic_pointer_cast<TwitchChannel>(channel);
|
||||||
|
if (!twitchChannel) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (twitchChannel->roomID == channelID) {
|
||||||
|
return twitchChannel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Channel::getEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
QString TwitchServer::cleanChannelName(const QString &dirtyChannelName)
|
QString TwitchServer::cleanChannelName(const QString &dirtyChannelName)
|
||||||
{
|
{
|
||||||
return dirtyChannelName.toLower();
|
return dirtyChannelName.toLower();
|
||||||
|
|
|
@ -20,6 +20,8 @@ public:
|
||||||
// fourtf: ugh
|
// fourtf: ugh
|
||||||
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
||||||
|
|
||||||
|
std::shared_ptr<Channel> getChannelOrEmptyByID(const QString &channelID);
|
||||||
|
|
||||||
const ChannelPtr whispersChannel;
|
const ChannelPtr whispersChannel;
|
||||||
const ChannelPtr mentionsChannel;
|
const ChannelPtr mentionsChannel;
|
||||||
IndirectChannel watchingChannel;
|
IndirectChannel watchingChannel;
|
||||||
|
|
Loading…
Reference in a new issue