mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
feat(emote-popup): automatically reload Twitch emotes (#5580)
This commit is contained in:
parent
820aa12af6
commit
61b04dbe7b
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -71,6 +71,7 @@ public:
|
|||
pajlada::Signals::Signal<const std::vector<MessagePtr> &> 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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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<TextElement>("no emotes available",
|
||||
MessageElementFlag::Text,
|
||||
MessageColor::System);
|
||||
|
@ -129,7 +131,7 @@ void addTwitchEmoteSets(const std::shared_ptr<const EmoteMap> &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>("", Channel::Type::None);
|
||||
auto globalChannel = std::make_shared<Channel>("", Channel::Type::None);
|
||||
auto channelChannel = std::make_shared<Channel>("", Channel::Type::None);
|
||||
this->globalEmotesView_->setChannel(
|
||||
std::make_shared<Channel>("", Channel::Type::None));
|
||||
this->subEmotesView_->setChannel(
|
||||
std::make_shared<Channel>("", Channel::Type::None));
|
||||
this->channelEmotesView_->setChannel(
|
||||
std::make_shared<Channel>("", 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;
|
||||
|
|
|
@ -52,6 +52,8 @@ private:
|
|||
void addShortcuts() override;
|
||||
bool eventFilter(QObject *object, QEvent *event) override;
|
||||
|
||||
void reloadEmotes();
|
||||
|
||||
void saveBounds() const;
|
||||
};
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<QUuid> &ids);
|
||||
|
|
Loading…
Reference in a new issue