Skip to content

Commit

Permalink
Removed ability to reload emotes really fast (Chatterino#3450)
Browse files Browse the repository at this point in the history
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
  • Loading branch information
Mm2PL and pajlada authored Jan 3, 2022
1 parent ac925d2 commit 79db02a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
- Bugfix: Fixed using special chars in Windows username breaking the storage of custom commands (#3397)
- Bugfix: Fixed character counter changing fonts after going over the limit. (#3422)
- Bugfix: Fixed crash that could occur if the user opens/closes ChannelViews (e.g. EmotePopup, or Splits) then modifies the showLastMessageIndicator setting. (#3444)
- Bugfix: Removed ability to reload emotes really fast (#3450)
- Dev: Batch checking live status for channels with live notifications that aren't connected. (#3442)
- Dev: Add GitHub action to test builds without precompiled headers enabled. (#3327)
- Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103)
Expand Down
18 changes: 18 additions & 0 deletions src/widgets/splits/SplitHeader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,15 @@ void SplitHeader::themeChangedEvent()

void SplitHeader::reloadChannelEmotes()
{
using namespace std::chrono_literals;

auto now = std::chrono::steady_clock::now();
if (this->lastReloadedChannelEmotes_ + 30s > now)
{
return;
}
this->lastReloadedChannelEmotes_ = now;

auto channel = this->split_->getChannel();

if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
Expand All @@ -924,6 +933,15 @@ void SplitHeader::reloadChannelEmotes()

void SplitHeader::reloadSubscriberEmotes()
{
using namespace std::chrono_literals;

auto now = std::chrono::steady_clock::now();
if (this->lastReloadedSubEmotes_ + 30s > now)
{
return;
}
this->lastReloadedSubEmotes_ = now;

auto channel = this->split_->getChannel();
getApp()->accounts->twitch.getCurrent()->loadEmotes(channel);
}
Expand Down
2 changes: 2 additions & 0 deletions src/widgets/splits/SplitHeader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class SplitHeader final : public BaseWidget
bool isLive_{false};
QString thumbnail_;
QElapsedTimer lastThumbnail_;
std::chrono::steady_clock::time_point lastReloadedChannelEmotes_;
std::chrono::steady_clock::time_point lastReloadedSubEmotes_;

// ui
Button *dropdownButton_{};
Expand Down

0 comments on commit 79db02a

Please sign in to comment.