feat: dynamically track mutability of messages (#6367)

This commit is contained in:
nerix
2025-08-04 21:04:59 +02:00
committed by GitHub
parent 0085b64418
commit 4ffdc2fa7b
171 changed files with 233 additions and 0 deletions
+1
View File
@@ -107,6 +107,7 @@ QJsonObject Message::toJson() const
{"count"_L1, static_cast<qint64>(this->count)},
{"serverReceivedTime"_L1,
this->serverReceivedTime.toString(Qt::ISODate)},
{"frozen"_L1, this->frozen},
};
QJsonArray badges;
+15
View File
@@ -86,6 +86,16 @@ struct Message {
};
ReplyStatus isReplyable() const;
uint32_t count = 1;
/// Can this message be modified?
///
/// Our rendering and layout code expects messages to be mostly immutable.
/// Thus, when this flag is set, this message may not be modified.
/// Only flags and this member can be modified safely (from the GUI thread).
/// This is only used for plugins right now. This value is only ever set to
/// true.
mutable bool frozen = false;
std::vector<std::unique_ptr<MessageElement>> elements;
ScrollbarHighlight getScrollBarHighlight() const;
@@ -93,6 +103,11 @@ struct Message {
std::shared_ptr<ChannelPointReward> reward = nullptr;
QJsonObject toJson() const;
void freeze() const
{
this->frozen = true;
}
};
} // namespace chatterino