mirror-chatterino2/src/messages/search/SubtierPredicate.cpp
nerix 1043f9f803
Remove Unnecessary Includes in Headers (#4275)
* refactor: remove unnecessary includes in headers

* fix: formatting

* chore: changelog

* fix: scrollbar

* fix: suggestions and old appbase remains

* fix: suggestion

* fix: missing Qt forward declarations

* fix: another qt include

* fix: includes for precompiled-headers=off

* Add missing `<memory>` includes

* Add missing `#pragma once`

* Fix tests

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
2022-12-31 14:41:01 +00:00

35 lines
860 B
C++

#include "messages/search/SubtierPredicate.hpp"
#include "messages/Message.hpp"
#include "providers/twitch/TwitchBadge.hpp"
#include "util/Qt.hpp"
namespace chatterino {
SubtierPredicate::SubtierPredicate(const QString &subtiers, bool negate)
: MessagePredicate(negate)
{
// Check if any comma-seperated values were passed and transform those
for (const auto &subtier : subtiers.split(',', Qt::SkipEmptyParts))
{
this->subtiers_ << subtier;
}
}
bool SubtierPredicate::appliesToImpl(const Message &message)
{
for (const Badge &badge : message.badges)
{
if (badge.key_ == "subscriber")
{
const auto &subTier =
badge.value_.length() > 3 ? badge.value_.at(0) : '1';
return subtiers_.contains(subTier);
}
}
return false;
}
} // namespace chatterino