diff --git a/CHANGELOG.md b/CHANGELOG.md index a259793b0..b6bcda5cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ - 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) @@ -42,7 +43,7 @@ - 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) +- 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) diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index b33726151..a74aa32c4 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -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; diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index 67e715af5..554327622 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -71,6 +71,7 @@ public: pajlada::Signals::Signal &> filledInMessages; pajlada::Signals::NoArgSignal destroyed; pajlada::Signals::NoArgSignal displayNameChanged; + pajlada::Signals::NoArgSignal messagesCleared; Type getType() const; const QString &getName() const; @@ -99,6 +100,9 @@ public: 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; diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 7f047d21f..c54e37741 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -240,6 +240,11 @@ void TwitchChannel::refreshTwitchChannelEmotes(bool manualRefresh) return; } + if (manualRefresh) + { + getApp()->getAccounts()->twitch.getCurrent()->reloadEmotes(this); + } + // Twitch's 'Get User Emotes' doesn't assigns a different set-ID to follower // emotes compared to subscriber emotes. QString setID = TWITCH_SUB_EMOTE_SET_PREFIX % this->roomId(); @@ -302,11 +307,6 @@ void TwitchChannel::refreshTwitchChannelEmotes(bool manualRefresh) qCWarning(chatterinoTwitch) << "Failed to get following status:" << error; }); - - if (manualRefresh) - { - getApp()->getAccounts()->twitch.getCurrent()->reloadEmotes(this); - } } void TwitchChannel::refreshBTTVChannelEmotes(bool manualRefresh) diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 28f67dc11..156d0882d 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -78,6 +78,8 @@ auto makeEmoteMessage(const EmoteMap &map, const MessageElementFlag &emoteFlag) if (map.empty()) { MessageBuilder builder; + builder->flags.set(MessageFlag::Centered); + builder->flags.set(MessageFlag::DisableCompactEmotes); builder.emplace("no emotes available", MessageElementFlag::Text, MessageColor::System); @@ -129,7 +131,7 @@ void addTwitchEmoteSets(const std::shared_ptr &local, { if (!local->empty()) { - addEmotes(subChannel, *local, channelName % u" (follower)", + addEmotes(subChannel, *local, channelName % u" (Follower)", MessageElementFlag::TwitchEmote); } @@ -293,6 +295,17 @@ EmotePopup::EmotePopup(QWidget *parent) }); this->search_->setFocus(); + + this->signalHolder_.managedConnect( + getApp()->getAccounts()->twitch.emotesReloaded, + [this](auto * /*caller*/, const auto &result) { + if (!result) + { + // some error occurred, no need to reload + return; + } + this->reloadEmotes(); + }); } void EmotePopup::addShortcuts() @@ -402,9 +415,30 @@ void EmotePopup::loadChannel(ChannelPtr channel) return; } - auto subChannel = std::make_shared("", Channel::Type::None); - auto globalChannel = std::make_shared("", Channel::Type::None); - auto channelChannel = std::make_shared("", Channel::Type::None); + this->globalEmotesView_->setChannel( + std::make_shared("", Channel::Type::None)); + this->subEmotesView_->setChannel( + std::make_shared("", Channel::Type::None)); + this->channelEmotesView_->setChannel( + std::make_shared("", Channel::Type::None)); + + this->reloadEmotes(); +} + +void EmotePopup::reloadEmotes() +{ + if (this->twitchChannel_ == nullptr) + { + return; + } + + auto subChannel = this->subEmotesView_->underlyingChannel(); + auto globalChannel = this->globalEmotesView_->underlyingChannel(); + auto channelChannel = this->channelEmotesView_->underlyingChannel(); + + subChannel->clearMessages(); + globalChannel->clearMessages(); + channelChannel->clearMessages(); // twitch addTwitchEmoteSets( @@ -447,10 +481,6 @@ void EmotePopup::loadChannel(ChannelPtr channel) "7TV", MessageElementFlag::SevenTVEmote); } - this->globalEmotesView_->setChannel(globalChannel); - this->subEmotesView_->setChannel(subChannel); - this->channelEmotesView_->setChannel(channelChannel); - if (subChannel->getMessageSnapshot().size() == 0) { MessageBuilder builder; diff --git a/src/widgets/dialogs/EmotePopup.hpp b/src/widgets/dialogs/EmotePopup.hpp index 85b5aa5c4..d93a4c933 100644 --- a/src/widgets/dialogs/EmotePopup.hpp +++ b/src/widgets/dialogs/EmotePopup.hpp @@ -52,6 +52,8 @@ private: void addShortcuts() override; bool eventFilter(QObject *object, QEvent *event) override; + void reloadEmotes(); + void saveBounds() const; }; diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 441d5b3c6..ab0e63226 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -897,6 +897,11 @@ ChannelPtr ChannelView::channel() return this->channel_; } +ChannelPtr ChannelView::underlyingChannel() const +{ + return this->underlyingChannel_; +} + bool ChannelView::showScrollbarHighlights() const { return this->channel_->getType() != Channel::Type::TwitchMentions; @@ -976,6 +981,11 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel) this->channel_->fillInMissingMessages(filtered); }); + this->channelConnections_.managedConnect(underlyingChannel->messagesCleared, + [this]() { + this->clearMessages(); + }); + // Copy over messages from the backing channel to the filtered one // and the ui. auto snapshot = underlyingChannel->getMessageSnapshot(); diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index f9f68bc2c..64683aca6 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -144,9 +144,20 @@ public: /// filter settings. It will always be of type Channel, not TwitchChannel /// nor IrcChannel. /// It's **not** equal to the channel passed in #setChannel(). + /// @see #underlyingChannel() ChannelPtr channel(); - /// Set the channel this view is displaying + /// @brief The channel this view displays messages for + /// + /// This channel potentially contains more messages than visible in this + /// view due to filter settings. + /// It's equal to the channel passed in #setChannel(). + /// @see #channel() + ChannelPtr underlyingChannel() const; + + /// @brief Set the channel this view is displaying + /// + /// @see #underlyingChannel() void setChannel(const ChannelPtr &underlyingChannel); void setFilters(const QList &ids);