feat: add ability to limit message snapshot size (#6602)
Reviewed-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -71,11 +71,17 @@ bool Channel::hasMessages() const
|
||||
return !this->messages_.empty();
|
||||
}
|
||||
|
||||
LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot()
|
||||
LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot() const
|
||||
{
|
||||
return this->messages_.getSnapshot();
|
||||
}
|
||||
|
||||
LimitedQueueSnapshot<MessagePtr> Channel::getMessageSnapshot(
|
||||
size_t nItems) const
|
||||
{
|
||||
return this->messages_.lastN(nItems);
|
||||
}
|
||||
|
||||
void Channel::addMessage(MessagePtr message, MessageContext context,
|
||||
std::optional<MessageFlags> overridingFlags)
|
||||
{
|
||||
@@ -117,7 +123,7 @@ void Channel::addSystemMessage(const QString &contents)
|
||||
void Channel::addOrReplaceTimeout(MessagePtr message, const QDateTime &now)
|
||||
{
|
||||
addOrReplaceChannelTimeout(
|
||||
this->getMessageSnapshot(), std::move(message), now,
|
||||
this->getMessageSnapshot(20), std::move(message), now,
|
||||
[this](auto /*idx*/, auto msg, auto replacement) {
|
||||
this->replaceMessage(msg, replacement);
|
||||
},
|
||||
@@ -130,7 +136,7 @@ void Channel::addOrReplaceTimeout(MessagePtr message, const QDateTime &now)
|
||||
void Channel::addOrReplaceClearChat(MessagePtr message, const QDateTime &now)
|
||||
{
|
||||
addOrReplaceChannelClear(
|
||||
this->getMessageSnapshot(), std::move(message), now,
|
||||
this->getMessageSnapshot(20), std::move(message), now,
|
||||
[this](auto /*idx*/, auto msg, auto replacement) {
|
||||
this->replaceMessage(msg, replacement);
|
||||
},
|
||||
|
||||
@@ -79,7 +79,8 @@ public:
|
||||
virtual const QString &getLocalizedName() const;
|
||||
bool isTwitchChannel() const;
|
||||
virtual bool isEmpty() const;
|
||||
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot();
|
||||
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot() const;
|
||||
LimitedQueueSnapshot<MessagePtr> getMessageSnapshot(size_t nItems) const;
|
||||
|
||||
// MESSAGES
|
||||
// overridingFlags can be filled in with flags that should be used instead
|
||||
|
||||
Reference in New Issue
Block a user