refactor: Message (#4915)

* Helix: Remove static from anon namespace

* Message: Remove empty anon namespace

* Message: Remove else after return

* Message: Avoid repeating type in return

* Message: Remove ScrollbarHighlight alias

* Message: Remove unused includes

* AttachedWindow: Remove unused include
This commit is contained in:
pajlada 2023-11-02 15:48:12 +01:00 committed by GitHub
parent 03b32bffc8
commit 4e63a1b6ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 43 deletions

View file

@ -1,18 +1,11 @@
#include "messages/Message.hpp"
#include "Application.hpp"
#include "MessageElement.hpp"
#include "providers/colors/ColorProvider.hpp"
#include "providers/twitch/PubSubActions.hpp"
#include "providers/twitch/TwitchBadge.hpp"
#include "singletons/Settings.hpp"
#include "singletons/Theme.hpp"
#include "util/DebugCount.hpp"
#include "util/IrcHelpers.hpp"
#include "widgets/helper/ScrollbarHighlight.hpp"
using SBHighlight = chatterino::ScrollbarHighlight;
namespace chatterino {
Message::Message()
@ -26,45 +19,57 @@ Message::~Message()
DebugCount::decrease("messages");
}
SBHighlight Message::getScrollBarHighlight() const
ScrollbarHighlight Message::getScrollBarHighlight() const
{
if (this->flags.has(MessageFlag::Highlighted) ||
this->flags.has(MessageFlag::HighlightedWhisper))
{
return SBHighlight(this->highlightColor);
}
else if (this->flags.has(MessageFlag::Subscription) &&
getSettings()->enableSubHighlight)
{
return SBHighlight(
ColorProvider::instance().color(ColorType::Subscription));
}
else if (this->flags.has(MessageFlag::RedeemedHighlight) ||
this->flags.has(MessageFlag::RedeemedChannelPointReward))
{
return SBHighlight(
ColorProvider::instance().color(ColorType::RedeemedHighlight),
SBHighlight::Default, true);
}
else if (this->flags.has(MessageFlag::ElevatedMessage))
{
return SBHighlight(ColorProvider::instance().color(
ColorType::ElevatedMessageHighlight),
SBHighlight::Default, false, false, true);
}
else if (this->flags.has(MessageFlag::FirstMessage))
{
return SBHighlight(
ColorProvider::instance().color(ColorType::FirstMessageHighlight),
SBHighlight::Default, false, true);
return {
this->highlightColor,
};
}
return SBHighlight();
if (this->flags.has(MessageFlag::Subscription) &&
getSettings()->enableSubHighlight)
{
return {
ColorProvider::instance().color(ColorType::Subscription),
};
}
if (this->flags.has(MessageFlag::RedeemedHighlight) ||
this->flags.has(MessageFlag::RedeemedChannelPointReward))
{
return {
ColorProvider::instance().color(ColorType::RedeemedHighlight),
ScrollbarHighlight::Default,
true,
};
}
if (this->flags.has(MessageFlag::ElevatedMessage))
{
return {
ColorProvider::instance().color(
ColorType::ElevatedMessageHighlight),
ScrollbarHighlight::Default,
false,
false,
true,
};
}
if (this->flags.has(MessageFlag::FirstMessage))
{
return {
ColorProvider::instance().color(ColorType::FirstMessageHighlight),
ScrollbarHighlight::Default,
false,
true,
};
}
return {};
}
// Static
namespace {
} // namespace
} // namespace chatterino

View file

@ -14,9 +14,9 @@ namespace {
using namespace chatterino;
static constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100;
constexpr auto NUM_MODERATORS_TO_FETCH_PER_REQUEST = 100;
static constexpr auto NUM_CHATTERS_TO_FETCH = 1000;
constexpr auto NUM_CHATTERS_TO_FETCH = 1000;
} // namespace

View file

@ -2,7 +2,6 @@
#include "Application.hpp"
#include "common/QLogging.hpp"
#include "ForwardDecl.hpp"
#include "singletons/Settings.hpp"
#include "util/DebugCount.hpp"
#include "widgets/splits/Split.hpp"