mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Resolved review
This commit is contained in:
parent
c08eaa4640
commit
5c602fea94
3 changed files with 13 additions and 31 deletions
|
@ -751,7 +751,8 @@ void TwitchChannel::refreshCheerEmotes()
|
|||
{
|
||||
auto cheerEmoteSet = CheerEmoteSet();
|
||||
cheerEmoteSet.regex = QRegularExpression(
|
||||
"^" + set.prefix.toLower() + "([1-9][0-9]*)$");
|
||||
"^" + set.prefix + "([1-9][0-9]*)$",
|
||||
QRegularExpression::CaseInsensitiveOption);
|
||||
|
||||
for (auto &tier : set.tiers)
|
||||
{
|
||||
|
@ -823,14 +824,12 @@ boost::optional<EmotePtr> TwitchChannel::ffzCustomModBadge() const
|
|||
return boost::none;
|
||||
}
|
||||
|
||||
boost::optional<std::tuple<boost::optional<EmotePtr>, boost::optional<EmotePtr>,
|
||||
boost::optional<QColor>>>
|
||||
TwitchChannel::cheerEmote(const QString &string)
|
||||
boost::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
|
||||
{
|
||||
auto sets = this->cheerEmoteSets_.access();
|
||||
for (const auto &set : *sets)
|
||||
{
|
||||
auto match = set.regex.match(string.toLower());
|
||||
auto match = set.regex.match(string);
|
||||
if (!match.hasMatch())
|
||||
{
|
||||
continue;
|
||||
|
@ -846,21 +845,7 @@ boost::optional<std::tuple<boost::optional<EmotePtr>, boost::optional<EmotePtr>,
|
|||
{
|
||||
if (bitAmount >= emote.minBits)
|
||||
{
|
||||
using OPEP = boost::optional<EmotePtr>;
|
||||
std::tuple<OPEP, OPEP, boost::optional<QColor>> retval;
|
||||
if (emote.staticEmote)
|
||||
{
|
||||
std::get<0>(retval) = emote.staticEmote;
|
||||
}
|
||||
if (emote.animatedEmote)
|
||||
{
|
||||
std::get<1>(retval) = emote.animatedEmote;
|
||||
}
|
||||
if (emote.color != QColor())
|
||||
{
|
||||
std::get<2>(retval) = emote.color;
|
||||
}
|
||||
return retval;
|
||||
return emote;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,10 +93,7 @@ public:
|
|||
const QString &version) const;
|
||||
|
||||
// Cheers
|
||||
boost::optional<
|
||||
std::tuple<boost::optional<EmotePtr>, boost::optional<EmotePtr>,
|
||||
boost::optional<QColor>>>
|
||||
cheerEmote(const QString &string);
|
||||
boost::optional<CheerEmote> cheerEmote(const QString &string);
|
||||
|
||||
// Signals
|
||||
pajlada::Signals::NoArgSignal roomIdChanged;
|
||||
|
|
|
@ -1292,21 +1292,21 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
|||
{
|
||||
return Failure;
|
||||
}
|
||||
auto &cheerPairAndColor = *cheerOpt;
|
||||
if (std::get<0>(cheerPairAndColor))
|
||||
auto &cheerEmote = *cheerOpt;
|
||||
if (cheerEmote.staticEmote)
|
||||
{
|
||||
this->emplace<EmoteElement>(*std::get<0>(cheerPairAndColor),
|
||||
this->emplace<EmoteElement>(cheerEmote.staticEmote,
|
||||
MessageElementFlag::BitsStatic);
|
||||
}
|
||||
if (std::get<1>(cheerPairAndColor))
|
||||
if (cheerEmote.animatedEmote)
|
||||
{
|
||||
this->emplace<EmoteElement>(*std::get<1>(cheerPairAndColor),
|
||||
this->emplace<EmoteElement>(cheerEmote.animatedEmote,
|
||||
MessageElementFlag::BitsAnimated);
|
||||
}
|
||||
if (std::get<2>(cheerPairAndColor))
|
||||
if (cheerEmote.color != QColor())
|
||||
{
|
||||
this->emplace<TextElement>(this->bits, MessageElementFlag::BitsAmount,
|
||||
*std::get<2>(cheerPairAndColor));
|
||||
cheerEmote.color);
|
||||
}
|
||||
return Success;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue