Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Message #4915

Merged
merged 9 commits into from
Nov 2, 2023
Merged
65 changes: 35 additions & 30 deletions src/messages/Message.cpp
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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);
return {
this->highlightColor,
};
}
else if (this->flags.has(MessageFlag::Subscription) &&
getSettings()->enableSubHighlight)

if (this->flags.has(MessageFlag::Subscription) &&
getSettings()->enableSubHighlight)
{
return SBHighlight(
ColorProvider::instance().color(ColorType::Subscription));
return {
ColorProvider::instance().color(ColorType::Subscription),
};
}
else if (this->flags.has(MessageFlag::RedeemedHighlight) ||
this->flags.has(MessageFlag::RedeemedChannelPointReward))

if (this->flags.has(MessageFlag::RedeemedHighlight) ||
this->flags.has(MessageFlag::RedeemedChannelPointReward))
{
return SBHighlight(
return {
ColorProvider::instance().color(ColorType::RedeemedHighlight),
SBHighlight::Default, true);
ScrollbarHighlight::Default,
true,
};
}
else if (this->flags.has(MessageFlag::ElevatedMessage))

if (this->flags.has(MessageFlag::ElevatedMessage))
{
return SBHighlight(ColorProvider::instance().color(
ColorType::ElevatedMessageHighlight),
SBHighlight::Default, false, false, true);
return {
ColorProvider::instance().color(
ColorType::ElevatedMessageHighlight),
ScrollbarHighlight::Default,
false,
false,
true,
};
}
else if (this->flags.has(MessageFlag::FirstMessage))

if (this->flags.has(MessageFlag::FirstMessage))
{
return SBHighlight(
return {
ColorProvider::instance().color(ColorType::FirstMessageHighlight),
SBHighlight::Default, false, true);
ScrollbarHighlight::Default,
false,
true,
};
Comment on lines +64 to +69
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not from this PR: The ScrollbarHighlight needs some refactoring. The arguments isRedeemedHighlight,
isFirstMessageHighlight, and isElevatedMessageHighlight are mutually exclusive - shouldn't this be refactored to an enum? Even if they're not mutually exclusive, a bit field would be more readable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely should be enums yeah

}

return SBHighlight();
return {};
}

// Static
namespace {

} // namespace

} // namespace chatterino
4 changes: 2 additions & 2 deletions src/providers/twitch/api/Helix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 0 additions & 1 deletion src/widgets/AttachedWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Loading