From 6151cd5b058c1623d652800effc088971d66e0a3 Mon Sep 17 00:00:00 2001 From: James Upjohn Date: Sun, 8 Aug 2021 22:59:28 +1200 Subject: [PATCH] Show system message when reloading subscriber emotes (#3135) Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/providers/twitch/TwitchAccount.cpp | 9 +++++++-- src/providers/twitch/TwitchAccount.hpp | 2 +- src/widgets/splits/Split.cpp | 2 +- src/widgets/splits/SplitHeader.cpp | 7 ++----- src/widgets/splits/SplitHeader.hpp | 1 - 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d864f1d7..397e15c2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unversioned - Minor: Remove TwitchEmotes.com attribution and the open/copy options when right-clicking a Twitch Emote. (#2214, #3136) +- Minor: Display a system message when reloading subscription emotes to match BTTV/FFZ behavior (#3135) - Bugfix: Moderation mode and active filters are now preserved when opening a split as a popup. (#3113, #3130) - Bugfix: Fixed a bug that caused all badge highlights to use the same color. (#3132, #3134) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index 237ba2df0..786a0cbe3 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -198,7 +198,7 @@ SharedAccessGuard> TwitchAccount::accessBlockedUserIds() return this->ignoresUserIds_.accessConst(); } -void TwitchAccount::loadEmotes() +void TwitchAccount::loadEmotes(std::weak_ptr weakChannel) { qCDebug(chatterinoTwitch) << "Loading Twitch emotes for user" << this->getUserName(); @@ -220,9 +220,14 @@ void TwitchAccount::loadEmotes() // TODO(zneix): Once Helix adds Get User Emotes we could remove this hacky solution // For now, this is necessary as Kraken's equivalent doesn't return all emotes // See: https://twitch.uservoice.com/forums/310213-developers/suggestions/43599900 - this->loadUserstateEmotes([=] { + this->loadUserstateEmotes([this, weakChannel] { // Fill up emoteData with emote sets that were returned in a Kraken call, but aren't present in emoteData. this->loadKrakenEmotes(); + if (auto channel = weakChannel.lock(); channel != nullptr) + { + channel->addMessage( + makeSystemMessage("Twitch subscriber emotes reloaded.")); + } }); } diff --git a/src/providers/twitch/TwitchAccount.hpp b/src/providers/twitch/TwitchAccount.hpp index 36e7d0ad6..034912a24 100644 --- a/src/providers/twitch/TwitchAccount.hpp +++ b/src/providers/twitch/TwitchAccount.hpp @@ -111,7 +111,7 @@ public: SharedAccessGuard> accessBlockedUserIds() const; SharedAccessGuard> accessBlocks() const; - void loadEmotes(); + void loadEmotes(std::weak_ptr weakChannel = {}); // loadUserstateEmotes loads emote sets that are part of the USERSTATE emote-sets key // this function makes sure not to load emote sets that have already been loaded void loadUserstateEmotes(std::function callback); diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 2263ee7fc..8c84a1476 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -870,8 +870,8 @@ void Split::showSearch() void Split::reloadChannelAndSubscriberEmotes() { - getApp()->accounts->twitch.getCurrent()->loadEmotes(); auto channel = this->getChannel(); + getApp()->accounts->twitch.getCurrent()->loadEmotes(channel); if (auto twitchChannel = dynamic_cast(channel.get())) { diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index 894391b38..635e3135f 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -916,10 +916,6 @@ void SplitHeader::themeChangedEvent() } } -void SplitHeader::moveSplit() -{ -} - void SplitHeader::reloadChannelEmotes() { auto channel = this->split_->getChannel(); @@ -933,7 +929,8 @@ void SplitHeader::reloadChannelEmotes() void SplitHeader::reloadSubscriberEmotes() { - getApp()->accounts->twitch.getCurrent()->loadEmotes(); + auto channel = this->split_->getChannel(); + getApp()->accounts->twitch.getCurrent()->loadEmotes(channel); } void SplitHeader::reconnect() diff --git a/src/widgets/splits/SplitHeader.hpp b/src/widgets/splits/SplitHeader.hpp index 4e68c717d..dea611ac2 100644 --- a/src/widgets/splits/SplitHeader.hpp +++ b/src/widgets/splits/SplitHeader.hpp @@ -85,7 +85,6 @@ private: std::vector channelConnections_; public slots: - void moveSplit(); void reloadChannelEmotes(); void reloadSubscriberEmotes(); void reconnect();