-
-
Notifications
You must be signed in to change notification settings - Fork 474
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
feat: add setting for showing pronouns in user info popup #5442
feat: add setting for showing pronouns in user info popup #5442
Conversation
Some comments before I make a proper review: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 25 out of 56. Check the log or trigger a new build to see more.
I think it should be easily possible to fetch on a timer, although I'm not familiar enough with the code base to know how or where timers are usually registered and run. Could you give me a pointer to where timers are usually placed? There was a "recent chatters" variable somewhere iirc, we could use this to occasionally on timer fetch pronouns for those. Alejo.io unfortunately, to my understanding, has no documentation for the API at all, PronounDB has a documentation at https://pronoundb.org/wiki/api-docs and mentions setting a User-Agent (which should be set, as
I just realized I read and then completely skipped the entire It also seems some things are broken on windows build (I think it's some |
Any sort of nitpicks or windows/macos/linux-specific things you can't fix can be easily fixed by any of our other contributors as part of the review process - we don't 100% listen to clang-tidy, so you can make a judgement call whether you care to listen to it For the timer thing, I can bring up some example when I do my review of this PR in the weekend. |
Alright that sounds good! I'll go through the code again later or tomorrow.
Sounds good! When will you be reviewing? I might force-push new changes to my branch, but if needed I can just create a new branch and work on that.
I've already created a checkbox in the settings menu to opt-out, I'll default it to disable then, which should also disable fetching. |
I should be able to get a full review in on Saturday on Sunday on my stream, can delay to Sunday (or to whenever) if you want more time before I take a look We Squash & Merge here, so you don't have to keep commits clean, I just prefer no force pushes after I've started reviewing |
To fix compilation on Windows, you need to add an diff --git a/src/providers/pronouns/pronoundb/PronounsPronounDbApi.cpp b/src/providers/pronouns/pronoundb/PronounsPronounDbApi.cpp
index ca39f70f..728aed67 100644
--- a/src/providers/pronouns/pronoundb/PronounsPronounDbApi.cpp
+++ b/src/providers/pronouns/pronoundb/PronounsPronounDbApi.cpp
@@ -111,7 +111,7 @@ void PronounsPronounDbApi::fetch(std::vector<PronounUser> allUsers, IPronounsApi
auto request = std::make_shared<IPronounsApi::RequestT>(allUsers.size(), std::move(onDone));
for (std::size_t i {0}; i < allUsers.size(); i += 50) {
- auto end = static_cast<std::size_t>(std::min(allUsers.size() - i, 50ul));
+ auto end = std::min(allUsers.size() - i, 50ull);
auto users = std::vector<PronounUser>(allUsers.begin() + i, allUsers.begin() + i + end);
NetworkRequest(PronounsPronounDbApi::makeRequest(users)) Just some general comments:
|
You can (and probably should) leave these changes until the implementation has been reviewed
this is the same as i mentioned above |
488b6a7
to
d72b09c
Compare
I just noticed both of you had commented since I last checked (and before I pushed)! @Nerixyz will do! The latest version now queues users for fetching when messages arrive and are regularly dequeued and fetched in a batch. I don't think the alejo.io API supports batch requests and the (open-source) browser extension fetches per message too, but I still added a limit to avoid completely flooding it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 25 out of 55. Check the log or trigger a new build to see more.
|
||
namespace chatterino { | ||
|
||
class IPronounsApi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: destructor of 'IPronounsApi' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
class IPronounsApi
^
Additional context
src/providers/pronouns/IPronounsApi.hpp:13: make it public and virtual
class IPronounsApi
^
using RequestT = PronounsApiRequest<ResultT>; | ||
|
||
// Fetch pronouns from the API. | ||
virtual void fetch(std::vector<PronounUser> users, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'users' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
virtual void fetch(std::vector<PronounUser> users,
^
|
||
// Fetch pronouns from the API. | ||
virtual void fetch(std::vector<PronounUser> users, | ||
RequestT::CallbackT &&onDone){}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: rvalue reference parameter 'onDone' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
RequestT::CallbackT &&onDone){};
^
namespace chatterino { | ||
|
||
PronounUser::PronounUser() | ||
: id{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: initializer for member 'id' is redundant [readability-redundant-member-init]
: id{} | |
: |
|
||
PronounUser::PronounUser() | ||
: id{} | ||
, username{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: initializer for member 'username' is redundant [readability-redundant-member-init]
, username{} | |
, |
} | ||
UserPronouns::UserPronouns(std::string pronouns) | ||
{ | ||
if (pronouns.length() == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the 'empty' method should be used to check for emptiness instead of 'length' [readability-container-size-empty]
if (pronouns.length() == 0) | |
if (pronouns.empty()) |
Additional context
/usr/include/c++/13/bits/basic_string.h:1219: method 'basic_string'::empty() defined here
empty() const _GLIBCXX_NOEXCEPT
^
UserPronouns(); | ||
UserPronouns(std::string); | ||
|
||
inline std::string format() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'format' has inline specifier but is implicitly inlined [readability-redundant-inline-specifier]
inline std::string format() const | |
std::string format() const |
/*static*/ std::optional<std::unordered_map<std::string, std::string>> | ||
PronounsAlejoApi::pronounsFromId = {}; | ||
|
||
/*static*/ UserPronouns PronounsAlejoApi::parse(QJsonObject object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'parse' can be made static [readability-convert-member-functions-to-static]
/*static*/ UserPronouns PronounsAlejoApi::parse(QJsonObject object) | |
/*static*/ static UserPronouns PronounsAlejoApi::parse(QJsonObject object) |
/*static*/ std::optional<std::unordered_map<std::string, std::string>> | ||
PronounsAlejoApi::pronounsFromId = {}; | ||
|
||
/*static*/ UserPronouns PronounsAlejoApi::parse(QJsonObject object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: out-of-line definition of 'parse' does not match any declaration in 'chatterino::PronounsAlejoApi' [clang-diagnostic-error]
/*static*/ UserPronouns PronounsAlejoApi::parse(QJsonObject object)
^
My main issue I outlined in #3346 was that alejo almost certainly can't keep up with the amount of requests we'd send, that 2 different implementations would return a different subset of users with pronouns, and it falls to blaming Chatterino if this feature we add works very sporadically (e.g. user reaction to bttv live emote updates) pronounsdb does look like it could better handle the brunt of our requests in comparison though |
PronounDB really does seem to handle it better, but it is unfortunately less widely used at least in the channels I've been lurking in. I'm wondering how alejo.io is working in the first place, as it seems that the browser extension is working in a flooding way too. If this is the intended way, and the way it is already implemented in its own browser extension, I don't see what sets apart Chatterino from just using a browser with the extension enabled (and then flooding the server in very lively channels). |
Browser chat is 1 channel and Chatterino is up to 100 |
True. I suppose only queuing new users on message in the active tab leads to the aforementioned weird sporadic behaviour? |
My recommendation is to only display the pronouns in the usercard - this minimizes http requests and avoids implementation complexity (of batching requests or caching thousands of pronouns) I understand that the usercard approach reduces the convenience factor for this feature, but the technical challenges (in my opinion) puts us in a situation where we need to apply more pressure on Twitch to natively support pronouns (to display it inline with each chat message). Similar to the no-video and no-audio badges, there should be he,she,they badges natively selectable on Twitch, which would be very easy for us to support in a scalable manner |
not even just a badge, pronouns sent in the tags would be fine too (don't care about people who hate tags, they work) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There were too many comments to post at once. Showing the first 25 out of 53. Check the log or trigger a new build to see more.
|
||
namespace chatterino { | ||
|
||
class IPronounsApi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: destructor of 'IPronounsApi' is public and non-virtual [cppcoreguidelines-virtual-class-destructor]
class IPronounsApi
^
Additional context
src/providers/pronouns/IPronounsApi.hpp:13: make it public and virtual
class IPronounsApi
^
using RequestT = PronounsApiRequest<ResultT>; | ||
|
||
// Fetch pronouns from the API. | ||
virtual void fetch(std::vector<PronounUser> users, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'users' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
virtual void fetch(std::vector<PronounUser> users,
^
|
||
// Fetch pronouns from the API. | ||
virtual void fetch(std::vector<PronounUser> users, | ||
RequestT::CallbackT &&onDone){}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: rvalue reference parameter 'onDone' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
RequestT::CallbackT &&onDone){};
^
namespace chatterino { | ||
|
||
PronounUser::PronounUser() | ||
: id{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: initializer for member 'id' is redundant [readability-redundant-member-init]
: id{} | |
: |
|
||
PronounUser::PronounUser() | ||
: id{} | ||
, username{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: initializer for member 'username' is redundant [readability-redundant-member-init]
, username{} | |
, |
UserPronouns(); | ||
UserPronouns(std::string); | ||
|
||
inline std::string format() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: function 'format' has inline specifier but is implicitly inlined [readability-redundant-inline-specifier]
inline std::string format() const | |
std::string format() const |
/*static*/ std::optional<std::unordered_map<std::string, std::string>> | ||
PronounsAlejoApi::pronounsFromId = {}; | ||
|
||
/*static*/ UserPronouns PronounsAlejoApi::parse(QJsonObject object) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: method 'parse' can be made static [readability-convert-member-functions-to-static]
/*static*/ UserPronouns PronounsAlejoApi::parse(QJsonObject object) | |
/*static*/ static UserPronouns PronounsAlejoApi::parse(QJsonObject object) |
else | ||
{ | ||
return {}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: do not use 'else' after 'return' [llvm-else-after-return]
} | |
return {}; | |
NetworkRequest(PronounsAlejoApi::API_URL + PronounsAlejoApi::API_USERS + | ||
"/" + user.username) | ||
.concurrent() | ||
.onSuccess([request, user](auto result) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no viable conversion from '(lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24)' to 'NetworkSuccessCallback' (aka 'function<void (NetworkResult)>') [clang-diagnostic-error]
.onSuccess([request, user](auto result) {
^
Additional context
/usr/include/c++/13/bits/std_function.h:374: candidate constructor not viable: no known conversion from '(lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24)' to 'nullptr_t' (aka 'std::nullptr_t') for 1st argument
function(nullptr_t) noexcept
^
/usr/include/c++/13/bits/std_function.h:385: candidate constructor not viable: no known conversion from '(lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24)' to 'const function<void (NetworkResult)> &' for 1st argument
function(const function& __x)
^
/usr/include/c++/13/bits/std_function.h:403: candidate constructor not viable: no known conversion from '(lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24)' to 'function<void (NetworkResult)> &&' for 1st argument
function(function&& __x) noexcept
^
/usr/include/c++/13/bits/std_function.h:434: candidate template ignored: requirement '_Callable<(lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24), (lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24), std::__invoke_result<(lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24) &, chatterino::NetworkResult>>::value' was not satisfied [with _Functor = (lambda at /github/workspace/src/providers/pronouns/alejo/PronounsAlejoApi.cpp:134:24)]
function(_Functor&& __f)
^
src/common/network/NetworkRequest.hpp:46: passing argument to parameter 'cb' here
NetworkRequest onSuccess(NetworkSuccessCallback cb) &&;
^
I don't think I'll be able to update the PR this weekend, but I've installed the clang LS extension and I starting working through the suggestions yesterday. The owner of PronounDB also replied yesterday I'll read it carefully tomorrow or so and share her comments. Apologies for accidentally closing the PR yesterday, I was scrolling through the comments and somehow clicked "Close" 😒 |
Alright, I'll wait with reviewing the PR until you've had a chance to look at it further then. Poke me! |
I would be fine with that compromise @treuks |
compromise is good; i'm not a maintainer but could be easier to review if 2 separate prs |
Awesome! I'll try to merge and remove the draft tag. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
benchmarks/src/RecentMessages.cpp
Outdated
@@ -124,6 +129,7 @@ class MockApplication : public mock::BaseApplication | |||
FfzEmotes ffzEmotes; | |||
SeventvEmotes seventvEmotes; | |||
DisabledStreamerMode streamerMode; | |||
Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: field has incomplete type 'chatterino::pronouns::Pronouns' [clang-diagnostic-error]
Pronouns pronouns;
^
Additional context
src/Application.hpp:56: forward declaration of 'chatterino::pronouns::Pronouns'
class Pronouns;
^
benchmarks/src/RecentMessages.cpp
Outdated
@@ -124,6 +129,7 @@ | |||
FfzEmotes ffzEmotes; | |||
SeventvEmotes seventvEmotes; | |||
DisabledStreamerMode streamerMode; | |||
Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: unknown type name 'Pronouns'; did you mean 'chatterino::pronouns::Pronouns'? [clang-diagnostic-error]
Pronouns pronouns; | |
chatterino::pronouns::Pronouns pronouns; |
Additional context
src/Application.hpp:56: 'chatterino::pronouns::Pronouns' declared here
class Pronouns;
^
tests/src/InputCompletion.cpp
Outdated
AccountController accounts; | ||
mock::MockTwitchIrcServer twitch; | ||
Emotes emotes; | ||
BttvEmotes bttvEmotes; | ||
FfzEmotes ffzEmotes; | ||
SeventvEmotes seventvEmotes; | ||
Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: field has incomplete type 'chatterino::pronouns::Pronouns' [clang-diagnostic-error]
Pronouns pronouns;
^
Additional context
src/Application.hpp:56: forward declaration of 'chatterino::pronouns::Pronouns'
class Pronouns;
^
tests/src/InputCompletion.cpp
Outdated
AccountController accounts; | ||
mock::MockTwitchIrcServer twitch; | ||
Emotes emotes; | ||
BttvEmotes bttvEmotes; | ||
FfzEmotes ffzEmotes; | ||
SeventvEmotes seventvEmotes; | ||
Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: unknown type name 'Pronouns'; did you mean 'chatterino::pronouns::Pronouns'? [clang-diagnostic-error]
Pronouns pronouns; | |
chatterino::pronouns::Pronouns pronouns; |
Additional context
src/Application.hpp:56: 'chatterino::pronouns::Pronouns' declared here
class Pronouns;
^
tests/src/MessageBuilder.cpp
Outdated
@@ -91,6 +91,20 @@ class MockApplication : public mock::BaseApplication | |||
return &this->seventvEmotes; | |||
} | |||
|
|||
<<<<<<< HEAD:tests/src/TwitchMessageBuilder.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: version control conflict marker in file [clang-diagnostic-error]
<<<<<<< HEAD:tests/src/TwitchMessageBuilder.cpp
^
tests/src/MessageBuilder.cpp
Outdated
@@ -102,6 +116,7 @@ | |||
BttvEmotes bttvEmotes; | |||
FfzEmotes ffzEmotes; | |||
SeventvEmotes seventvEmotes; | |||
Pronouns::Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: field has incomplete type 'pronouns::Pronouns' [clang-diagnostic-error]
Pronouns::Pronouns pronouns;
^
Additional context
src/Application.hpp:56: forward declaration of 'chatterino::pronouns::Pronouns'
class Pronouns;
^
tests/src/MessageBuilder.cpp
Outdated
@@ -102,6 +116,7 @@ | |||
BttvEmotes bttvEmotes; | |||
FfzEmotes ffzEmotes; | |||
SeventvEmotes seventvEmotes; | |||
Pronouns::Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: use of undeclared identifier 'Pronouns'; did you mean 'pronouns'? [clang-diagnostic-error]
Pronouns::Pronouns pronouns; | |
pronouns::Pronouns pronouns; |
Additional context
src/Application.hpp:55: 'pronouns' declared here
namespace pronouns {
^
qCDebug(chatterinoPronouns) << "Fetching available pronouns for alejo.io"; | ||
NetworkRequest(AlejoApi::API_URL + AlejoApi::API_PRONOUNS) | ||
.concurrent() | ||
.cache() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How well or not well does this handle caching?
From my cursory glance at the caching system, I can see a scenario where:
- the data gets loaded and saved to cache
- a user adds themselves to the database
- this gets loaded from cache but still has the old data.
Even restarting Chatterino probably wouldn't help because the cached data will still be in cache and it will just be reloaded.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is only for the pronouns (i.e. some-pronoun-id → "they/them") not for the users, thus it's not frequently updated. But I agree that it should be removed, because we don't have any way of invalidating this.
How can I run the benchmarks, tests, etc. on my machine? I'm getting In any case, I've pushed some changes that should hopefully fix the build errors. |
Are you sure you properly checked out all submodules ( |
I didn't, that was definitely it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
tests/src/InputCompletion.cpp
Outdated
AccountController accounts; | ||
mock::MockTwitchIrcServer twitch; | ||
Emotes emotes; | ||
BttvEmotes bttvEmotes; | ||
FfzEmotes ffzEmotes; | ||
SeventvEmotes seventvEmotes; | ||
pronouns::Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: field has incomplete type 'pronouns::Pronouns' [clang-diagnostic-error]
pronouns::Pronouns pronouns;
^
Additional context
src/Application.hpp:56: forward declaration of 'chatterino::pronouns::Pronouns'
class Pronouns;
^
tests/src/MessageBuilder.cpp
Outdated
@@ -102,6 +108,7 @@ class MockApplication : public mock::BaseApplication | |||
BttvEmotes bttvEmotes; | |||
FfzEmotes ffzEmotes; | |||
SeventvEmotes seventvEmotes; | |||
pronouns::Pronouns pronouns; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: field has incomplete type 'pronouns::Pronouns' [clang-diagnostic-error]
pronouns::Pronouns pronouns;
^
Additional context
src/Application.hpp:56: forward declaration of 'chatterino::pronouns::Pronouns'
class Pronouns;
^
Seems like I still can't push things, weird Here's a patch you can apply which will make it build diff --git a/benchmarks/src/RecentMessages.cpp b/benchmarks/src/RecentMessages.cpp
index fd3461a7d..994c88858 100644
--- a/benchmarks/src/RecentMessages.cpp
+++ b/benchmarks/src/RecentMessages.cpp
@@ -11,6 +11,7 @@
#include "providers/chatterino/ChatterinoBadges.hpp"
#include "providers/ffz/FfzBadges.hpp"
#include "providers/ffz/FfzEmotes.hpp"
+#include "providers/pronouns/Pronouns.hpp"
#include "providers/recentmessages/Impl.hpp"
#include "providers/seventv/SeventvBadges.hpp"
#include "providers/seventv/SeventvEmotes.hpp"
diff --git a/src/Application.cpp b/src/Application.cpp
index 7f805fa1d..24dd346fd 100644
--- a/src/Application.cpp
+++ b/src/Application.cpp
@@ -187,36 +187,6 @@ Application::Application(Settings &_settings, const Paths &paths,
Application::~Application()
{
-#ifdef CHATTERINO_HAVE_PLUGINS
- this->plugins.reset();
-#endif
- this->twitchPubSub.reset();
- this->twitchBadges.reset();
- this->twitchLiveController.reset();
- this->chatterinoBadges.reset();
- this->bttvEmotes.reset();
- this->ffzEmotes.reset();
- this->seventvEmotes.reset();
- this->notifications.reset();
- this->commands.reset();
- // If a crash happens after crashHandler has been reset, we'll assert
- // This isn't super different from before, where if the app is already killed, the getApp() portion of it is already dead
- this->crashHandler.reset();
- this->seventvAPI.reset();
- this->highlights.reset();
- this->seventvBadges.reset();
- this->ffzBadges.reset();
- // this->twitch.reset();
- this->imageUploader.reset();
- this->hotkeys.reset();
- this->fonts.reset();
- this->sound.reset();
- this->userData.reset();
- this->toasts.reset();
- this->accounts.reset();
- this->emotes.reset();
- this->themes.reset();
- this->pronouns.reset();
// we do this early to ensure getApp isn't used in any dtors
INSTANCE = nullptr;
}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 5ed9e2457..8aec2c5bb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -348,12 +348,12 @@ set(SOURCE_FILES
providers/liveupdates/BasicPubSubManager.hpp
providers/liveupdates/BasicPubSubWebsocket.hpp
- providers/pronouns/Pronouns.hpp
providers/pronouns/Pronouns.cpp
- providers/pronouns/UserPronouns.hpp
+ providers/pronouns/Pronouns.hpp
providers/pronouns/UserPronouns.cpp
- providers/pronouns/alejo/PronounsAlejoApi.hpp
+ providers/pronouns/UserPronouns.hpp
providers/pronouns/alejo/PronounsAlejoApi.cpp
+ providers/pronouns/alejo/PronounsAlejoApi.hpp
providers/recentmessages/Api.cpp
providers/recentmessages/Api.hpp
diff --git a/src/providers/pronouns/alejo/PronounsAlejoApi.cpp b/src/providers/pronouns/alejo/PronounsAlejoApi.cpp
index 0d2cfe834..31e606016 100644
--- a/src/providers/pronouns/alejo/PronounsAlejoApi.cpp
+++ b/src/providers/pronouns/alejo/PronounsAlejoApi.cpp
@@ -114,7 +114,7 @@ void AlejoApi::fetch(const QString &username,
return;
}
qCWarning(chatterinoPronouns)
- << "alejo.io returned " << status
+ << "alejo.io returned " << status.value_or(-1)
<< " when fetching pronouns for " << username;
onDone({});
})
diff --git a/tests/src/InputCompletion.cpp b/tests/src/InputCompletion.cpp
index cbf4fcc65..460fb1526 100644
--- a/tests/src/InputCompletion.cpp
+++ b/tests/src/InputCompletion.cpp
@@ -69,18 +69,12 @@ public:
return &this->seventvEmotes;
}
- pronouns::Pronouns *getPronouns() override
- {
- return &this->pronouns;
- }
-
AccountController accounts;
mock::MockTwitchIrcServer twitch;
Emotes emotes;
BttvEmotes bttvEmotes;
FfzEmotes ffzEmotes;
SeventvEmotes seventvEmotes;
- pronouns::Pronouns pronouns;
};
} // namespace
diff --git a/tests/src/MessageBuilder.cpp b/tests/src/MessageBuilder.cpp
index c2a68d16a..39f01f196 100644
--- a/tests/src/MessageBuilder.cpp
+++ b/tests/src/MessageBuilder.cpp
@@ -91,12 +91,6 @@ public:
return &this->seventvEmotes;
}
- pronouns::Pronouns *getPronouns() override
- {
- return &this->pronouns;
- }
-
- Settings settings;
AccountController accounts;
Emotes emotes;
mock::UserDataController userData;
@@ -108,7 +102,6 @@ public:
BttvEmotes bttvEmotes;
FfzEmotes ffzEmotes;
SeventvEmotes seventvEmotes;
- pronouns::Pronouns pronouns;
};
} // namespace |
probably because this branch is on a chatterino7 fork, not chatterino2 |
Oh yeah that's possible. I just applied the patch and pushed, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
} | ||
|
||
void AlejoApi::fetch(const QString &username, | ||
std::function<void(std::optional<UserPronouns>)> onDone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: the parameter 'onDone' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
src/providers/pronouns/alejo/PronounsAlejoApi.hpp:21:
- std::function<void(std::optional<UserPronouns>)> onDone);
+ const std::function<void(std::optional<UserPronouns>)>& onDone);
std::function<void(std::optional<UserPronouns>)> onDone) | |
const std::function<void(std::optional<UserPronouns>)>& onDone) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some nitpicking, will take another round of checks once these things have been done.
Functionally, the PR works almost as I'd expect. Thanks for taking the time to look into this, and I look forward to merge this in
qCDebug(chatterinoPronouns) | ||
<< "Fetching pronouns from alejo.io for " << username; | ||
|
||
alejoApi.fetch(username, [this, callbackSuccess, callbackFail, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirming this is correct, and that you can ignore this. I will fix this in a follow-up PR
} | ||
|
||
qCDebug(chatterinoPronouns) << "Fetching available pronouns for alejo.io"; | ||
NetworkRequest(AlejoApi::API_URL + AlejoApi::API_PRONOUNS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if this network request is only made if the pronoun setting is enabled.
For reference, check out the BttvEmotes
ctor.
If you want the request to be made in the constructor, which I think is fine for a network request this small, leave the autoInvoke
param out (or set to true, its default value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is functionally mostly good, I will merge this in and follow-up with another PR cleaning some things up
Thank you! As a first-time contributor, you are now eligible to be listed in the About page in Chatterino. If you want this, you can open a new PR where you modify the |
Common pronoun providers like alejo.io and pronoundb.org have respective browser extensions for twitch, but so far Chatterino does not support these providers.
I have now implemented a provider that fetches pronouns from APIs.

Pronoun providers can be configured in code, where, if multiple are configured the latter ones serve as a fallback for the former ones.
Right now, pronoundb.org and pronouns.alejo.io are implemented.
Pronouns are fetched when a message from a new user arrives and is cached application wide per session (as opposed to cache per tab). Pronouns are not added to the first message from a user. In the future, pronouns could be added to previous messages too.
For future-proofing, it is possible to fetch pronouns for multiple users at once, but right now, pronouns are fetched per-message if required.