From a75a42387b7b5a99907a5b8371c3ac59fa4c078e Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Fri, 5 Jan 2024 16:17:05 +0100 Subject: [PATCH 1/3] fix: unnecessary notebook-tab updates --- src/widgets/helper/NotebookTab.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 1d7ac523db3..0f53ab9bf0a 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) + + if (!this->highlightEnabled_ && + newHighlightStyle == HighlightState::NewMessage) { - this->highlightState_ = newHighlightStyle; + return; + } - this->update(); + if (this->highlightState_ == newHighlightStyle || + this->highlightState_ == HighlightState::Highlighted) + { + return; } + + this->highlightState_ = newHighlightStyle; + this->update(); } void NotebookTab::setHighlightsEnabled(const bool &newVal) From 95bca60d2e06f06df423b28d9b1af37459cef4a3 Mon Sep 17 00:00:00 2001 From: Nerixyz Date: Fri, 5 Jan 2024 16:23:01 +0100 Subject: [PATCH 2/3] chore: add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ee79f733c4..7b1f58769a0 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 From bea3ca4fa44a9b1dc363b33478003de33e59e02c Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 6 Jan 2024 11:47:43 +0100 Subject: [PATCH 3/3] Fix NotebookTab test --- tests/src/NotebookTab.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/src/NotebookTab.cpp b/tests/src/NotebookTab.cpp index 3731d4022dc..56a14989890 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);