diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index bc532da3b..362cc39e8 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -535,64 +535,64 @@ ChannelPtr ChannelView::channel() return this->channel_; } -void ChannelView::setChannel(ChannelPtr newChannel) +void ChannelView::setChannel(ChannelPtr channel) { /// Clear connections from the last channel this->channelConnections_.clear(); this->clearMessages(); + this->scrollBar_->clearHighlights(); // on new message - this->channelConnections_.push_back(newChannel->messageAppended.connect( + this->channelConnections_.push_back(channel->messageAppended.connect( [this](MessagePtr &message, boost::optional overridingFlags) { this->messageAppended(message, overridingFlags); })); - this->channelConnections_.push_back( - newChannel->messagesAddedAtStart.connect( - [this](std::vector &messages) { - this->messageAddedAtStart(messages); - })); + this->channelConnections_.push_back(channel->messagesAddedAtStart.connect( + [this](std::vector &messages) { + this->messageAddedAtStart(messages); + })); // on message removed this->channelConnections_.push_back( - newChannel->messageRemovedFromStart.connect( - [this](MessagePtr &message) { - this->messageRemoveFromStart(message); - })); + channel->messageRemovedFromStart.connect([this](MessagePtr &message) { + this->messageRemoveFromStart(message); + })); // on message replaced - this->channelConnections_.push_back(newChannel->messageReplaced.connect( + this->channelConnections_.push_back(channel->messageReplaced.connect( [this](size_t index, MessagePtr replacement) { this->messageReplaced(index, replacement); })); - auto snapshot = newChannel->getMessageSnapshot(); + auto snapshot = channel->getMessageSnapshot(); for (size_t i = 0; i < snapshot.size(); i++) { MessageLayoutPtr deleted; - auto messageRef = new MessageLayout(snapshot[i]); + auto messageLayout = new MessageLayout(snapshot[i]); if (this->lastMessageHasAlternateBackground_) { - messageRef->flags.set(MessageLayoutFlag::AlternateBackground); + messageLayout->flags.set(MessageLayoutFlag::AlternateBackground); } this->lastMessageHasAlternateBackground_ = !this->lastMessageHasAlternateBackground_; - this->messages_.pushBack(MessageLayoutPtr(messageRef), deleted); + this->messages_.pushBack(MessageLayoutPtr(messageLayout), deleted); + this->scrollBar_->addHighlight(snapshot[i]->getScrollBarHighlight()); } - this->channel_ = newChannel; + this->channel_ = channel; this->queueLayout(); this->queueUpdate(); // Notifications - if (auto tc = dynamic_cast(newChannel.get())) + if (auto tc = dynamic_cast(channel.get())) { this->connections_.push_back(tc->liveStatusChanged.connect([this]() { this->liveStatusChanged.invoke(); //