Skip to content

refactor: turn Emotes into EmoteController - #6516

Merged
pajlada merged 6 commits into
Chatterino:masterfrom
Nerixyz:refactor/emote-controller
Oct 4, 2025
Merged

pajlada merged 6 commits into
Chatterino:masterfrom
Nerixyz:refactor/emote-controller

Conversation

@Nerixyz

@Nerixyz Nerixyz commented Oct 3, 2025

Copy link
Copy Markdown
Contributor

In Chatterino, "controller" is technically a euphemism for "singleton". One practical difference is that controllers have subdirectories (e.g. controllers/hotkeys) as opposed to singletons.
In #6436, I want to add some other classes related to emotes. Since they're semantically related, they should also be physically related by being in the same directory. Hence, this PR turns Emotes into an EmoteController. The controller has the following differences:

  • Removed IEmotes in favor of a virtual initialize() that subclasses can reimplement. This way, the accessors don't need to be virtual anymore.
  • Removed get prefix of trivial accessors.
  • Used unique_ptr for all members to avoid including too many files (e.g. TwitchEmotes.hpp).

@pajlada pajlada left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In Chatterino, "controller" is technically a euphemism for "singleton". One practical difference is that controllers have subdirectories (e.g. controllers/hotkeys) as opposed to singletons.

In Chatterino, singletons are something that are created & accessed statically, we just haven't renamed/moved classes out of that directory. Controllers are meant as Application-owned once-constructed "backends" for data.

Removed IEmotes in favor of a virtual initialize() that subclasses can reimplement. This way, the accessors don't need to be virtual anymore.

This removes the ability for us to mock the members of the emote controller (I know we haven't taken advantage of this). Do you foresee mocking of Emojis/TwitchEmotes or EmoteController to not be necessary?

When you say "...that subclasses can reimplement", what subclasses do you have in mind?

Comment thread src/Application.cpp Outdated
Comment thread src/controllers/emotes/EmoteController.hpp Outdated
@Nerixyz
Nerixyz force-pushed the refactor/emote-controller branch from 6274d3f to ac88010 Compare October 3, 2025 15:41
@Nerixyz

Nerixyz commented Oct 3, 2025

Copy link
Copy Markdown
Contributor Author

This removes the ability for us to mock the members of the emote controller (I know we haven't taken advantage of this). Do you foresee mocking of Emojis/TwitchEmotes or EmoteController to not be necessary?

I don't think we need to mock the members. The closest would be TwitchEmotes if it were to load some emotes over the network. However, that would happen in some initialization method. We can omit this potential call with the current design.

When you say "...that subclasses can reimplement", what subclasses do you have in mind?

The only subclass is the mock that omits initialization.

@pajlada
pajlada enabled auto-merge (squash) October 4, 2025 09:27
@pajlada
pajlada merged commit c5b0669 into Chatterino:master Oct 4, 2025
17 of 18 checks passed
babicekmarek pushed a commit to babicekmarek/streamally-chatterino that referenced this pull request Sep 14, 2026
* refactor: turn `Emotes` into `EmoteController`

* changelog

* why does clang-format do this???

* nit: remove unused include from EmoteController.hpp

---------

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants