mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fix(channel-view): use underlyingChannel_
over channel_
(#5248)
This commit is contained in:
parent
fc61e8d64d
commit
47c46b64ea
|
@ -109,6 +109,7 @@
|
|||
- Bugfix: Fixed the "Cancel" button in the settings dialog only working after opening the settings dialog twice. (#5229)
|
||||
- Bugfix: Fixed split header tooltips showing in the wrong position on Windows. (#5230)
|
||||
- Bugfix: Fixed split header tooltips appearing too tall. (#5232)
|
||||
- Bugfix: Fixed past messages not showing in the search popup after adding a channel. (#5248)
|
||||
- Dev: Run miniaudio in a separate thread, and simplify it to not manage the device ourselves. There's a chance the simplification is a bad idea. (#4978)
|
||||
- Dev: Change clang-format from v14 to v16. (#4929)
|
||||
- Dev: Fixed UTF16 encoding of `modes` file for the installer. (#4791)
|
||||
|
|
|
@ -453,7 +453,8 @@ void ChannelView::initializeSignals()
|
|||
this->signalHolder_.managedConnect(
|
||||
getIApp()->getWindows()->layoutRequested, [&](Channel *channel) {
|
||||
if (this->isVisible() &&
|
||||
(channel == nullptr || this->channel_.get() == channel))
|
||||
(channel == nullptr ||
|
||||
this->underlyingChannel_.get() == channel))
|
||||
{
|
||||
this->queueLayout();
|
||||
}
|
||||
|
@ -463,7 +464,8 @@ void ChannelView::initializeSignals()
|
|||
getIApp()->getWindows()->invalidateBuffersRequested,
|
||||
[this](Channel *channel) {
|
||||
if (this->isVisible() &&
|
||||
(channel == nullptr || this->channel_.get() == channel))
|
||||
(channel == nullptr ||
|
||||
this->underlyingChannel_.get() == channel))
|
||||
{
|
||||
this->invalidateBuffers();
|
||||
}
|
||||
|
@ -975,6 +977,41 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
this->channel_->fillInMissingMessages(filtered);
|
||||
});
|
||||
|
||||
// Copy over messages from the backing channel to the filtered one
|
||||
// and the ui.
|
||||
auto snapshot = underlyingChannel->getMessageSnapshot();
|
||||
|
||||
this->scrollBar_->setMaximum(qreal(snapshot.size()));
|
||||
|
||||
for (const auto &msg : snapshot)
|
||||
{
|
||||
if (!this->shouldIncludeMessage(msg))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
auto messageLayout = std::make_shared<MessageLayout>(msg);
|
||||
|
||||
if (this->lastMessageHasAlternateBackground_)
|
||||
{
|
||||
messageLayout->flags.set(MessageLayoutFlag::AlternateBackground);
|
||||
}
|
||||
this->lastMessageHasAlternateBackground_ =
|
||||
!this->lastMessageHasAlternateBackground_;
|
||||
|
||||
if (underlyingChannel->shouldIgnoreHighlights())
|
||||
{
|
||||
messageLayout->flags.set(MessageLayoutFlag::IgnoreHighlights);
|
||||
}
|
||||
|
||||
this->messages_.pushBack(messageLayout);
|
||||
this->channel_->addMessage(msg);
|
||||
if (this->showScrollbarHighlights())
|
||||
{
|
||||
this->scrollBar_->addHighlight(msg->getScrollBarHighlight());
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Standard channel connections
|
||||
//
|
||||
|
@ -1006,33 +1043,6 @@ void ChannelView::setChannel(const ChannelPtr &underlyingChannel)
|
|||
this->messagesUpdated();
|
||||
});
|
||||
|
||||
auto snapshot = underlyingChannel->getMessageSnapshot();
|
||||
|
||||
this->scrollBar_->setMaximum(qreal(snapshot.size()));
|
||||
|
||||
for (const auto &msg : snapshot)
|
||||
{
|
||||
auto messageLayout = std::make_shared<MessageLayout>(msg);
|
||||
|
||||
if (this->lastMessageHasAlternateBackground_)
|
||||
{
|
||||
messageLayout->flags.set(MessageLayoutFlag::AlternateBackground);
|
||||
}
|
||||
this->lastMessageHasAlternateBackground_ =
|
||||
!this->lastMessageHasAlternateBackground_;
|
||||
|
||||
if (underlyingChannel->shouldIgnoreHighlights())
|
||||
{
|
||||
messageLayout->flags.set(MessageLayoutFlag::IgnoreHighlights);
|
||||
}
|
||||
|
||||
this->messages_.pushBack(messageLayout);
|
||||
if (this->showScrollbarHighlights())
|
||||
{
|
||||
this->scrollBar_->addHighlight(msg->getScrollBarHighlight());
|
||||
}
|
||||
}
|
||||
|
||||
this->underlyingChannel_ = underlyingChannel;
|
||||
|
||||
this->performLayout();
|
||||
|
@ -2991,10 +3001,6 @@ void ChannelView::setInputReply(const MessagePtr &message)
|
|||
// Message did not already have a thread attached, try to find or create one
|
||||
auto *tc =
|
||||
dynamic_cast<TwitchChannel *>(this->underlyingChannel_.get());
|
||||
if (!tc)
|
||||
{
|
||||
tc = dynamic_cast<TwitchChannel *>(this->channel_.get());
|
||||
}
|
||||
|
||||
if (tc)
|
||||
{
|
||||
|
|
|
@ -139,15 +139,32 @@ public:
|
|||
|
||||
MessageElementFlags getFlags() const;
|
||||
|
||||
/// @brief The virtual channel used to display messages
|
||||
///
|
||||
/// This channel contains all messages in this view and respects the
|
||||
/// filter settings. It will always be of type Channel, not TwitchChannel
|
||||
/// nor IrcChannel.
|
||||
/// It's **not** equal to the channel passed in #setChannel().
|
||||
ChannelPtr channel();
|
||||
|
||||
/// Set the channel this view is displaying
|
||||
void setChannel(const ChannelPtr &underlyingChannel);
|
||||
|
||||
void setFilters(const QList<QUuid> &ids);
|
||||
QList<QUuid> getFilterIds() const;
|
||||
FilterSetPtr getFilterSet() const;
|
||||
|
||||
/// @brief The channel this is derived from
|
||||
///
|
||||
/// In case of "nested" channel views such as in user popups,
|
||||
/// this channel is set to the original channel the messages came from,
|
||||
/// which is used to open user popups from this view.
|
||||
/// It's not always set.
|
||||
/// @see #hasSourceChannel()
|
||||
ChannelPtr sourceChannel() const;
|
||||
/// Setter for #sourceChannel()
|
||||
void setSourceChannel(ChannelPtr sourceChannel);
|
||||
/// Checks if this view has a #sourceChannel
|
||||
bool hasSourceChannel() const;
|
||||
|
||||
LimitedQueueSnapshot<MessageLayoutPtr> &getMessagesSnapshot();
|
||||
|
@ -300,8 +317,31 @@ private:
|
|||
ThreadGuard snapshotGuard_;
|
||||
LimitedQueueSnapshot<MessageLayoutPtr> snapshot_;
|
||||
|
||||
/// @brief The backing (internal) channel
|
||||
///
|
||||
/// This is a "virtual" channel where all filtered messages from
|
||||
/// @a underlyingChannel_ are added to. It contains messages visible on
|
||||
/// screen and will always be a @a Channel, or, it will never be a
|
||||
/// TwitchChannel or IrcChannel, however, it will have the same type and
|
||||
/// name as @a underlyingChannel_. It's not know to any registry/server.
|
||||
ChannelPtr channel_ = nullptr;
|
||||
|
||||
/// @brief The channel receiving messages
|
||||
///
|
||||
/// This channel is the one passed in #setChannel(). It's known to the
|
||||
/// respective registry (e.g. TwitchIrcServer). For Twitch channels for
|
||||
/// example, this will be an instance of TwitchChannel. This channel might
|
||||
/// contain more messages than visible if filters are active.
|
||||
ChannelPtr underlyingChannel_ = nullptr;
|
||||
|
||||
/// @brief The channel @a underlyingChannel_ is derived from
|
||||
///
|
||||
/// In case of "nested" channel views such as in user popups,
|
||||
/// this channel is set to the original channel the messages came from,
|
||||
/// which is used to open user popups from this view.
|
||||
///
|
||||
/// @see #sourceChannel()
|
||||
/// @see #hasSourceChannel()
|
||||
ChannelPtr sourceChannel_ = nullptr;
|
||||
Split *split_;
|
||||
|
||||
|
|
Loading…
Reference in a new issue