mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fix: Avoid unnecessary NotebookTab
updates (#5068)
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
parent
99b537ffd9
commit
1192393039
|
@ -108,6 +108,7 @@
|
|||
- Dev: Refactor Args to be less of a singleton. (#5041)
|
||||
- Dev: Channels without any animated elements on screen will skip updates from the GIF timer. (#5042, #5043, #5045)
|
||||
- Dev: Autogenerate docs/plugin-meta.lua. (#5055)
|
||||
- Dev: Fix `NotebookTab` emitting updates for every message. (#5068)
|
||||
|
||||
## 2.4.6
|
||||
|
||||
|
|
|
@ -346,17 +346,25 @@ bool NotebookTab::isLive() const
|
|||
|
||||
void NotebookTab::setHighlightState(HighlightState newHighlightStyle)
|
||||
{
|
||||
if (this->isSelected() || (!this->highlightEnabled_ &&
|
||||
newHighlightStyle == HighlightState::NewMessage))
|
||||
if (this->isSelected())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (this->highlightState_ != HighlightState::Highlighted)
|
||||
{
|
||||
this->highlightState_ = newHighlightStyle;
|
||||
|
||||
this->update();
|
||||
if (!this->highlightEnabled_ &&
|
||||
newHighlightStyle == HighlightState::NewMessage)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->highlightState_ == newHighlightStyle ||
|
||||
this->highlightState_ == HighlightState::Highlighted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this->highlightState_ = newHighlightStyle;
|
||||
this->update();
|
||||
}
|
||||
|
||||
HighlightState NotebookTab::highlightState() const
|
||||
|
|
|
@ -91,8 +91,7 @@ TEST_F(NotebookTabFixture, UpgradeHighlightState)
|
|||
/// The highlight state must stay as NewMessage when called twice
|
||||
TEST_F(NotebookTabFixture, SameHighlightStateNewMessage)
|
||||
{
|
||||
// XXX: This only updates the state once, so it should only update once
|
||||
EXPECT_CALL(this->tab, update).Times(Exactly(2));
|
||||
EXPECT_CALL(this->tab, update).Times(Exactly(1));
|
||||
EXPECT_EQ(this->tab.highlightState(), HighlightState::None);
|
||||
this->tab.setHighlightState(HighlightState::NewMessage);
|
||||
EXPECT_EQ(this->tab.highlightState(), HighlightState::NewMessage);
|
||||
|
|
Loading…
Reference in a new issue