diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ee79f733..7b1f58769 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 7abd0f205..af75468c8 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -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 diff --git a/tests/src/NotebookTab.cpp b/tests/src/NotebookTab.cpp index 3731d4022..56a149898 100644 --- a/tests/src/NotebookTab.cpp +++ b/tests/src/NotebookTab.cpp @@ -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);