Skip to content

Commit

Permalink
fix: scroll to bottom when setting a channel (#5748)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerixyz authored Dec 2, 2024
1 parent 8faf243 commit 3c2a422
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
- Dev: 7TV's `entitlement.reset` is now explicitly ignored. (#5685)
- Dev: Qt 6.8 and later now default to the GDI fontengine. (#5710)
- Dev: Moved to condition variables when shutting down worker threads. (#5721, #5733)
- Dev: Reduced layouts in channel views when setting a channel. (#5737)
- Dev: Reduced layouts in channel views when setting a channel. (#5737, #5748)

## 2.5.1

Expand Down
5 changes: 3 additions & 2 deletions src/widgets/dialogs/EmotePopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ void addTwitchEmoteSets(const std::shared_ptr<const EmoteMap> &local,
void loadEmojis(ChannelView &view, const std::vector<EmojiPtr> &emojiMap)
{
ChannelPtr emojiChannel(new Channel("", Channel::Type::None));
// set the channel first to make sure the scrollbar is at the top
view.setChannel(emojiChannel);

emojiChannel->addMessage(makeEmojiMessage(emojiMap),
MessageContext::Original);

view.setChannel(emojiChannel);
}

void loadEmojis(Channel &channel, const std::vector<EmojiPtr> &emojiMap,
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/dialogs/ReplyThreadPopup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,9 +237,6 @@ void ReplyThreadPopup::addMessagesFromThread()
sourceChannel->getName(), Channel::Type::None);
}

this->ui_.threadView->setChannel(this->virtualChannel_);
this->ui_.threadView->setSourceChannel(sourceChannel);

auto rootOverrideFlags =
std::optional<MessageFlags>(this->thread_->root()->flags);
rootOverrideFlags->set(MessageFlag::DoNotLog);
Expand All @@ -258,6 +255,9 @@ void ReplyThreadPopup::addMessagesFromThread()
}
}

this->ui_.threadView->setChannel(this->virtualChannel_);
this->ui_.threadView->setSourceChannel(sourceChannel);

this->messageConnection_ =
std::make_unique<pajlada::Signals::ScopedConnection>(
sourceChannel->messageAppended.connect(
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/helper/ChannelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,13 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
this->updateID();

this->queueLayout();
if (!this->isVisible() && !this->scrollBar_->isVisible())
{
// If we're not visible and the scrollbar is not (yet) visible,
// we need to make sure that it's at the bottom when this view is laid
// out later.
this->scrollBar_->scrollToBottom();
}
this->queueUpdate();

// Notifications
Expand Down

0 comments on commit 3c2a422

Please sign in to comment.