Fix crash when adding recent messages to empty Channel (#3932)

* Fix crash when adding recent messages to empty Channel

* Update CHANGELOG.md
This commit is contained in:
Daniel Sage
2022-08-20 05:01:16 -04:00
committed by GitHub
parent c204332685
commit 33db006635
2 changed files with 14 additions and 1 deletions
+13
View File
@@ -237,7 +237,20 @@ void Channel::addMessagesAtStart(const std::vector<MessagePtr> &_messages)
void Channel::fillInMissingMessages(const std::vector<MessagePtr> &messages)
{
if (messages.empty())
{
return;
}
auto snapshot = this->getMessageSnapshot();
if (snapshot.size() == 0)
{
// There are no messages in this channel yet so we can just insert them
// at the front in order
this->messages_.pushFront(messages);
this->filledInMessages.invoke(messages);
return;
}
std::unordered_set<QString> existingMessageIds;
existingMessageIds.reserve(snapshot.size());