mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
Fixes #1259 highlight not added when changing channel
This commit is contained in:
parent
89fd3bfce9
commit
cadff4c430
1 changed files with 18 additions and 18 deletions
|
@ -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<MessageFlags> overridingFlags) {
|
||||
this->messageAppended(message, overridingFlags);
|
||||
}));
|
||||
|
||||
this->channelConnections_.push_back(
|
||||
newChannel->messagesAddedAtStart.connect(
|
||||
this->channelConnections_.push_back(channel->messagesAddedAtStart.connect(
|
||||
[this](std::vector<MessagePtr> &messages) {
|
||||
this->messageAddedAtStart(messages);
|
||||
}));
|
||||
|
||||
// on message removed
|
||||
this->channelConnections_.push_back(
|
||||
newChannel->messageRemovedFromStart.connect(
|
||||
[this](MessagePtr &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<TwitchChannel *>(newChannel.get()))
|
||||
if (auto tc = dynamic_cast<TwitchChannel *>(channel.get()))
|
||||
{
|
||||
this->connections_.push_back(tc->liveStatusChanged.connect([this]() {
|
||||
this->liveStatusChanged.invoke(); //
|
||||
|
|
Loading…
Reference in a new issue