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

Handle follower emotes differently if subscribed #4922

Merged
merged 11 commits into from
Nov 4, 2023
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unversioned

- Major: Allow use of Twitch follower emotes in other channels if subscribed. (#4922)
- Minor: Migrate to the new Get Channel Followers Helix endpoint, fixing follower count not showing up in usercards. (#4809)
- Minor: The account switcher is now styled to match your theme. (#4817)
- Minor: Add an invisible resize handle to the bottom of frameless user info popups and reply thread popups. (#4795)
Expand Down
28 changes: 27 additions & 1 deletion src/providers/twitch/TwitchAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,25 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
[this, weakChannel](QJsonArray emoteSetArray) {
auto emoteData = this->emotes_.access();
auto localEmoteData = this->localEmotes_.access();

std::unordered_set<QString> subscriberChannelIDs;
for (auto emoteSet : emoteSetArray)
{
IvrEmoteSet ivrEmoteSet(emoteSet.toObject());
baines marked this conversation as resolved.
Show resolved Hide resolved
if (!ivrEmoteSet.tier.isNull())
{
subscriberChannelIDs.insert(ivrEmoteSet.channelId);
}
pajlada marked this conversation as resolved.
Show resolved Hide resolved
}

for (const auto &emoteSet : emoteData->emoteSets)
{
if (emoteSet->subscriber)
{
subscriberChannelIDs.insert(emoteSet->channelID);
}
}

for (auto emoteSet_ : emoteSetArray)
{
auto emoteSet = std::make_shared<EmoteSet>();
Expand All @@ -285,8 +304,13 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
continue;
}

emoteSet->channelID = ivrEmoteSet.channelId;
emoteSet->channelName = ivrEmoteSet.login;
emoteSet->text = ivrEmoteSet.displayName;
emoteSet->subscriber = !ivrEmoteSet.tier.isNull();

bool haveSubscriberSetForChannel =
baines marked this conversation as resolved.
Show resolved Hide resolved
subscriberChannelIDs.contains(ivrEmoteSet.channelId);
pajlada marked this conversation as resolved.
Show resolved Hide resolved

for (const auto &emoteObj : ivrEmoteSet.emotes)
{
Expand All @@ -302,7 +326,9 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
getApp()->emotes->twitch.getOrCreateEmote(id, code);

// Follower emotes can be only used in their origin channel
baines marked this conversation as resolved.
Show resolved Hide resolved
if (ivrEmote.emoteType == "FOLLOWER")
// unless the user is subscribed, then they can be used anywhere.
if (ivrEmote.emoteType == "FOLLOWER" &&
!haveSubscriberSetForChannel)
{
emoteSet->local = true;

Expand Down
2 changes: 2 additions & 0 deletions src/providers/twitch/TwitchAccount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class TwitchAccount : public Account
struct EmoteSet {
QString key;
QString channelName;
QString channelID;
QString text;
bool subscriber{false};
bool local{false};
std::vector<TwitchEmote> emotes;
};
Expand Down
Loading