Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into mr/pronouns-in-user…
Browse files Browse the repository at this point in the history
…card-alejoio
  • Loading branch information
DeltaTimo committed Sep 2, 2024
2 parents 3cedf4e + 61b04db commit fb05076
Show file tree
Hide file tree
Showing 54 changed files with 1,444 additions and 540 deletions.
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ CheckOptions:
- key: readability-identifier-naming.FunctionCase
value: camelBack
- key: readability-identifier-naming.FunctionIgnoredRegexp
value: ^TEST$
value: ^(TEST|MOCK_METHOD)$

- key: readability-identifier-naming.MemberCase
value: camelBack
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
build_dir: build-clang-tidy
config_file: ".clang-tidy"
split_workflow: true
exclude: "lib/*,tools/crash-handler/*"
exclude: "lib/*,tools/crash-handler/*,mocks/*"
cmake_command: >-
./.CI/setup-clang-tidy.sh
apt_packages: >-
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
matrix:
os: [macos-13]
qt-version: [5.15.2, 6.5.0]
qt-version: [5.15.2, 6.7.1]
plugins: [false]
fail-fast: false
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
include:
- os: "ubuntu-22.04"
container: ghcr.io/chatterino/chatterino2-build-ubuntu-22.04:latest
qt-version: 6.6.1
qt-version: 6.7.1
plugins: true
fail-fast: false
env:
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
- Minor: Links can now have prefixes and suffixes such as parentheses. (#5486, #5515)
- Minor: Added support for scrolling in splits with touchscreen panning gestures. (#5524)
- Minor: Removed experimental IRC support. (#5547)
- Minor: Moderators can now see which mods start and cancel raids. (#5563)
- Minor: The emote popup now reloads when Twitch emotes are reloaded. (#5580)
- Bugfix: Fixed tab move animation occasionally failing to start after closing a tab. (#5426)
- Bugfix: If a network request errors with 200 OK, Qt's error code is now reported instead of the HTTP status. (#5378)
- Bugfix: Fixed restricted users usernames not being clickable. (#5405)
Expand All @@ -36,14 +38,16 @@
- Bugfix: Fixed a crash when tab completing while having an invalid plugin loaded. (#5401)
- Bugfix: Fixed windows on Windows not saving correctly when snapping them to the edges. (#5478)
- Bugfix: Fixed user info card popups adding duplicate line to log files. (#5499)
- Bugfix: Fixed tooltips and input completion popups not working after moving a split. (#5541)
- Bugfix: Fixed tooltips and input completion popups not working after moving a split. (#5541, #5576)
- Bugfix: Fixed rare issue on shutdown where the client would hang. (#5557)
- Bugfix: Fixed `/clearmessages` not working with more than one window. (#5489)
- Bugfix: Fixed splits staying paused after unfocusing Chatterino in certain configurations. (#5504)
- Bugfix: Links with invalid characters in the domain are no longer detected. (#5509)
- Bugfix: Fixed janky selection for messages with RTL segments (selection is still wrong, but consistently wrong). (#5525)
- Bugfix: Fixed event emotes not showing up in autocomplete and popups. (#5239, #5580)
- Bugfix: Fixed tab visibility being controllable in the emote popup. (#5530)
- Bugfix: Fixed account switch not being saved if no other settings were changed. (#5558)
- Bugfix: Fixed some tooltips not being readable. (#5578)
- Dev: Update Windows build from Qt 6.5.0 to Qt 6.7.1. (#5420)
- Dev: Update vcpkg build Qt from 6.5.0 to 6.7.0, boost from 1.83.0 to 1.85.0, openssl from 3.1.3 to 3.3.0. (#5422)
- Dev: Unsingletonize `ISoundController`. (#5462)
Expand Down
7 changes: 7 additions & 0 deletions mocks/include/mocks/EmptyApplication.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,13 @@ class EmptyApplication : public IApplication
return nullptr;
}

ITwitchUsers *getTwitchUsers() override
{
assert(false && "EmptyApplication::getTwitchUsers was called without "
"being initialized");
return nullptr;
}

pronouns::Pronouns *getPronouns() override
{
assert(false && "EmptyApplication::getPronouns was called without "
Expand Down
17 changes: 17 additions & 0 deletions mocks/include/mocks/Helix.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,23 @@ class Helix : public IHelix
(FailureCallback<HelixSendMessageError, QString> failureCallback)),
(override));

// get user emotes
MOCK_METHOD(
void, getUserEmotes,
(QString userID, QString broadcasterID,
(ResultCallback<std::vector<HelixChannelEmote>, HelixPaginationState>
successCallback),
FailureCallback<QString> failureCallback, CancellationToken &&token),
(override));

// get followed channel
MOCK_METHOD(
void, getFollowedChannel,
(QString userID, QString broadcasterID,
ResultCallback<std::optional<HelixFollowedChannel>> successCallback,
FailureCallback<QString> failureCallback),
(override));

MOCK_METHOD(void, update, (QString clientId, QString oauthToken),
(override));

Expand Down
10 changes: 10 additions & 0 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "providers/twitch/PubSubMessages.hpp"
#include "providers/twitch/TwitchChannel.hpp"
#include "providers/twitch/TwitchIrcServer.hpp"
#include "providers/twitch/TwitchUsers.hpp"
#include "singletons/CrashHandler.hpp"
#include "singletons/Emotes.hpp"
#include "singletons/Fonts.hpp"
Expand Down Expand Up @@ -177,6 +178,7 @@ Application::Application(Settings &_settings, const Paths &paths,
, logging(new Logging(_settings))
, linkResolver(new LinkResolver)
, streamerMode(new StreamerMode)
, twitchUsers(new TwitchUsers)
, pronouns(std::make_shared<pronouns::Pronouns>())
#ifdef CHATTERINO_HAVE_PLUGINS
, plugins(new PluginController(paths))
Expand Down Expand Up @@ -517,6 +519,14 @@ IStreamerMode *Application::getStreamerMode()
return this->streamerMode.get();
}

ITwitchUsers *Application::getTwitchUsers()
{
assertInGuiThread();
assert(this->twitchUsers);

return this->twitchUsers.get();
}

BttvEmotes *Application::getBttvEmotes()
{
assertInGuiThread();
Expand Down
4 changes: 4 additions & 0 deletions src/Application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class SeventvEmotes;
class SeventvEventAPI;
class ILinkResolver;
class IStreamerMode;
class ITwitchUsers;
namespace pronouns {
class Pronouns;
} // namespace pronouns
Expand Down Expand Up @@ -106,6 +107,7 @@ class IApplication
virtual SeventvEventAPI *getSeventvEventAPI() = 0;
virtual ILinkResolver *getLinkResolver() = 0;
virtual IStreamerMode *getStreamerMode() = 0;
virtual ITwitchUsers *getTwitchUsers() = 0;
virtual pronouns::Pronouns *getPronouns() = 0;
};

Expand Down Expand Up @@ -170,6 +172,7 @@ class Application : public IApplication
const std::unique_ptr<Logging> logging;
std::unique_ptr<ILinkResolver> linkResolver;
std::unique_ptr<IStreamerMode> streamerMode;
std::unique_ptr<ITwitchUsers> twitchUsers;
std::shared_ptr<pronouns::Pronouns> pronouns;
#ifdef CHATTERINO_HAVE_PLUGINS
std::unique_ptr<PluginController> plugins;
Expand Down Expand Up @@ -221,6 +224,7 @@ class Application : public IApplication

ILinkResolver *getLinkResolver() override;
IStreamerMode *getStreamerMode() override;
ITwitchUsers *getTwitchUsers() override;

private:
void initBttvLiveUpdates();
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,8 @@ set(SOURCE_FILES
providers/twitch/TwitchIrcServer.hpp
providers/twitch/TwitchUser.cpp
providers/twitch/TwitchUser.hpp
providers/twitch/TwitchUsers.cpp
providers/twitch/TwitchUsers.hpp

providers/twitch/pubsubmessages/AutoMod.cpp
providers/twitch/pubsubmessages/AutoMod.hpp
Expand Down Expand Up @@ -478,6 +480,7 @@ set(SOURCE_FILES
util/DebugCount.hpp
util/DisplayBadge.cpp
util/DisplayBadge.hpp
util/Expected.hpp
util/FormatTime.cpp
util/FormatTime.hpp
util/FunctionEventFilter.cpp
Expand Down
1 change: 1 addition & 0 deletions src/PrecompiledHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# include <IrcCommand>
# include <IrcConnection>
# include <IrcMessage>
# include <nonstd/expected.hpp>
# include <pajlada/serialize.hpp>
# include <pajlada/settings/setting.hpp>
# include <pajlada/settings/settinglistener.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/RunGui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace {
dark.setColor(QPalette::Base, QColor("#333"));
dark.setColor(QPalette::AlternateBase, QColor("#444"));
dark.setColor(QPalette::ToolTipBase, Qt::white);
dark.setColor(QPalette::ToolTipText, Qt::white);
dark.setColor(QPalette::ToolTipText, Qt::black);
dark.setColor(QPalette::Dark, QColor(35, 35, 35));
dark.setColor(QPalette::Shadow, QColor(20, 20, 20));
dark.setColor(QPalette::Button, QColor(70, 70, 70));
Expand Down
58 changes: 35 additions & 23 deletions src/common/Aliases.hpp
Original file line number Diff line number Diff line change
@@ -1,38 +1,50 @@
#pragma once

#include <boost/container_hash/hash_fwd.hpp>
#include <QHash>
#include <QString>

#include <functional>

#define QStringAlias(name) \
namespace chatterino { \
struct name { \
QString string; \
bool operator==(const name &other) const \
{ \
return this->string == other.string; \
} \
bool operator!=(const name &other) const \
{ \
return this->string != other.string; \
} \
}; \
} /* namespace chatterino */ \
namespace std { \
template <> \
struct hash<chatterino::name> { \
size_t operator()(const chatterino::name &s) const \
{ \
return qHash(s.string); \
} \
}; \
} /* namespace std */
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define QStringAlias(name) \
namespace chatterino { \
struct name { \
QString string; \
bool operator==(const name &other) const \
{ \
return this->string == other.string; \
} \
bool operator!=(const name &other) const \
{ \
return this->string != other.string; \
} \
}; \
} /* namespace chatterino */ \
namespace std { \
template <> \
struct hash<chatterino::name> { \
size_t operator()(const chatterino::name &s) const \
{ \
return qHash(s.string); \
} \
}; \
} /* namespace std */ \
namespace boost { \
template <> \
struct hash<chatterino::name> { \
std::size_t operator()(chatterino::name const &s) const \
{ \
return qHash(s.string); \
} \
}; \
} /* namespace boost */

QStringAlias(UserName);
QStringAlias(UserId);
QStringAlias(Url);
QStringAlias(Tooltip);
QStringAlias(EmoteId);
QStringAlias(EmoteSetId);
QStringAlias(EmoteName);
QStringAlias(EmoteAuthor);
6 changes: 6 additions & 0 deletions src/common/Channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,12 @@ void Channel::deleteMessage(QString messageID)
}
}

void Channel::clearMessages()
{
this->messages_.clear();
this->messagesCleared.invoke();
}

MessagePtr Channel::findMessage(QString messageID)
{
MessagePtr res;
Expand Down
4 changes: 4 additions & 0 deletions src/common/Channel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ class Channel : public std::enable_shared_from_this<Channel>
pajlada::Signals::Signal<const std::vector<MessagePtr> &> filledInMessages;
pajlada::Signals::NoArgSignal destroyed;
pajlada::Signals::NoArgSignal displayNameChanged;
pajlada::Signals::NoArgSignal messagesCleared;

Type getType() const;
const QString &getName() const;
Expand Down Expand Up @@ -99,6 +100,9 @@ class Channel : public std::enable_shared_from_this<Channel>
void replaceMessage(size_t index, MessagePtr replacement);
void deleteMessage(QString messageID);

/// Removes all messages from this channel and invokes #messagesCleared
void clearMessages();

MessagePtr findMessage(QString messageID);

bool hasMessages() const;
Expand Down
9 changes: 4 additions & 5 deletions src/controllers/commands/builtin/twitch/Raid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,8 @@ QString startRaid(const CommandContext &ctx)
channel{ctx.channel}](const HelixUser &targetUser) {
getHelix()->startRaid(
twitchChannel->roomId(), targetUser.id,
[channel, targetUser] {
channel->addSystemMessage(QString("You started to raid %1.")
.arg(targetUser.displayName));
[] {
// do nothing
},
[channel, targetUser](auto error, auto message) {
auto errorMessage = formatStartRaidError(error, message);
Expand Down Expand Up @@ -202,8 +201,8 @@ QString cancelRaid(const CommandContext &ctx)

getHelix()->cancelRaid(
ctx.twitchChannel->roomId(),
[channel{ctx.channel}] {
channel->addSystemMessage("You cancelled the raid.");
[] {
// do nothing
},
[channel{ctx.channel}](auto error, auto message) {
auto errorMessage = formatCancelRaidError(error, message);
Expand Down
4 changes: 2 additions & 2 deletions src/controllers/commands/builtin/twitch/SendWhisper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ bool appendWhisperMessageWordsLocally(const QStringList &words)
for (int i = 2; i < words.length(); i++)
{
{ // Twitch emote
auto it = accemotes.emotes.find({words[i]});
if (it != accemotes.emotes.end())
auto it = accemotes->find({words[i]});
if (it != accemotes->end())
{
b.emplace<EmoteElement>(it->second,
MessageElementFlag::TwitchEmote);
Expand Down
22 changes: 6 additions & 16 deletions src/controllers/completion/sources/EmoteSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,26 +95,16 @@ void EmoteSource::initializeFromChannel(const Channel *channel)
// returns true also for special Twitch channels (/live, /mentions, /whispers, etc.)
if (channel->isTwitchChannel())
{
if (auto user = app->getAccounts()->twitch.getCurrent())
if (tc)
{
// Twitch Emotes available globally
auto emoteData = user->accessEmotes();
addEmotes(emotes, emoteData->emotes, "Twitch Emote");

// Twitch Emotes available locally
auto localEmoteData = user->accessLocalEmotes();
if ((tc != nullptr) &&
localEmoteData->find(tc->roomId()) != localEmoteData->end())
if (auto twitch = tc->localTwitchEmotes())
{
if (const auto *localEmotes = &localEmoteData->at(tc->roomId()))
{
addEmotes(emotes, *localEmotes, "Local Twitch Emotes");
}
addEmotes(emotes, *twitch, "Local Twitch Emotes");
}
}

if (tc)
{
auto user = getApp()->getAccounts()->twitch.getCurrent();
addEmotes(emotes, **user->accessEmotes(), "Twitch Emote");

// TODO extract "Channel {BetterTTV,7TV,FrankerFaceZ}" text into a #define.
if (auto bttv = tc->bttvEmotes())
{
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/ignores/IgnorePhrase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bool IgnorePhrase::containsEmote() const
for (const auto &acc : accvec)
{
const auto &accemotes = *acc->accessEmotes();
for (const auto &emote : accemotes.emotes)
for (const auto &emote : *accemotes)
{
if (this->replace_.contains(emote.first.string,
Qt::CaseSensitive))
Expand Down
Loading

0 comments on commit fb05076

Please sign in to comment.