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();
|
auto cheerEmoteSet = CheerEmoteSet();
|
||||||
cheerEmoteSet.regex = QRegularExpression(
|
cheerEmoteSet.regex = QRegularExpression(
|
||||||
"^" + set.prefix.toLower() + "([1-9][0-9]*)$");
|
"^" + set.prefix + "([1-9][0-9]*)$",
|
||||||
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
|
|
||||||
for (auto &tier : set.tiers)
|
for (auto &tier : set.tiers)
|
||||||
{
|
{
|
||||||
|
@ -823,14 +824,12 @@ boost::optional<EmotePtr> TwitchChannel::ffzCustomModBadge() const
|
||||||
return boost::none;
|
return boost::none;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::optional<std::tuple<boost::optional<EmotePtr>, boost::optional<EmotePtr>,
|
boost::optional<CheerEmote> TwitchChannel::cheerEmote(const QString &string)
|
||||||
boost::optional<QColor>>>
|
|
||||||
TwitchChannel::cheerEmote(const QString &string)
|
|
||||||
{
|
{
|
||||||
auto sets = this->cheerEmoteSets_.access();
|
auto sets = this->cheerEmoteSets_.access();
|
||||||
for (const auto &set : *sets)
|
for (const auto &set : *sets)
|
||||||
{
|
{
|
||||||
auto match = set.regex.match(string.toLower());
|
auto match = set.regex.match(string);
|
||||||
if (!match.hasMatch())
|
if (!match.hasMatch())
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
|
@ -846,21 +845,7 @@ boost::optional<std::tuple<boost::optional<EmotePtr>, boost::optional<EmotePtr>,
|
||||||
{
|
{
|
||||||
if (bitAmount >= emote.minBits)
|
if (bitAmount >= emote.minBits)
|
||||||
{
|
{
|
||||||
using OPEP = boost::optional<EmotePtr>;
|
return emote;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,10 +93,7 @@ public:
|
||||||
const QString &version) const;
|
const QString &version) const;
|
||||||
|
|
||||||
// Cheers
|
// Cheers
|
||||||
boost::optional<
|
boost::optional<CheerEmote> cheerEmote(const QString &string);
|
||||||
std::tuple<boost::optional<EmotePtr>, boost::optional<EmotePtr>,
|
|
||||||
boost::optional<QColor>>>
|
|
||||||
cheerEmote(const QString &string);
|
|
||||||
|
|
||||||
// Signals
|
// Signals
|
||||||
pajlada::Signals::NoArgSignal roomIdChanged;
|
pajlada::Signals::NoArgSignal roomIdChanged;
|
||||||
|
|
|
@ -1292,21 +1292,21 @@ Outcome TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
||||||
{
|
{
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
auto &cheerPairAndColor = *cheerOpt;
|
auto &cheerEmote = *cheerOpt;
|
||||||
if (std::get<0>(cheerPairAndColor))
|
if (cheerEmote.staticEmote)
|
||||||
{
|
{
|
||||||
this->emplace<EmoteElement>(*std::get<0>(cheerPairAndColor),
|
this->emplace<EmoteElement>(cheerEmote.staticEmote,
|
||||||
MessageElementFlag::BitsStatic);
|
MessageElementFlag::BitsStatic);
|
||||||
}
|
}
|
||||||
if (std::get<1>(cheerPairAndColor))
|
if (cheerEmote.animatedEmote)
|
||||||
{
|
{
|
||||||
this->emplace<EmoteElement>(*std::get<1>(cheerPairAndColor),
|
this->emplace<EmoteElement>(cheerEmote.animatedEmote,
|
||||||
MessageElementFlag::BitsAnimated);
|
MessageElementFlag::BitsAnimated);
|
||||||
}
|
}
|
||||||
if (std::get<2>(cheerPairAndColor))
|
if (cheerEmote.color != QColor())
|
||||||
{
|
{
|
||||||
this->emplace<TextElement>(this->bits, MessageElementFlag::BitsAmount,
|
this->emplace<TextElement>(this->bits, MessageElementFlag::BitsAmount,
|
||||||
*std::get<2>(cheerPairAndColor));
|
cheerEmote.color);
|
||||||
}
|
}
|
||||||
return Success;
|
return Success;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue