Automatically load recent messages on reconnect (#3878)
* Add working reconnect recent messages * Rename method to messagesUpdated * Use audo declarations * Add docs to new LimitedQueue methods * Add more documentation, try atomic loading flag * Update CHANGELOG.md * Remove unused include * Rename 'reconnected' signal to 'connected' * Reserve before filtering on arbitrary update * Extract recent messages fetching to own class * Use std::atomic_flag instead of std::atomic_bool * Add PostToThread include * Add chatterino.recentmessages logging * Remove unneeded parameters, lambda move capture * Remove TwitchChannel::buildRecentMessages * Add documentation, use more clear method name * Reword changelog entry I think it sounds better like this :) * Rework how filling in missing messages is handled This should hopefully prevent issues with filtered channels with old messages that no longer exist in the underlying channel * Check existing messages when looking for reply * Clean up string distribution in file * Try to improve documentation * Use std::function for RecentMessagesApi * Only trigger filledInMessages if we inserted * Remove old unused lines * Use make_shared<MessageLayout> instead of new MessageLayout * Alphabetize QLogging categories * Reorder CHANGELOG.md
This commit is contained in:
@@ -304,6 +304,8 @@ void IrcMessageHandler::populateReply(
|
||||
}
|
||||
}
|
||||
|
||||
MessagePtr foundMessage;
|
||||
|
||||
// Thread does not yet exist, find root reply and create thread.
|
||||
// Linear search is justified by the infrequent use of replies
|
||||
for (auto &otherMsg : otherLoaded)
|
||||
@@ -311,15 +313,29 @@ void IrcMessageHandler::populateReply(
|
||||
if (otherMsg->id == replyID)
|
||||
{
|
||||
// Found root reply message
|
||||
std::shared_ptr<MessageThread> newThread =
|
||||
std::make_shared<MessageThread>(otherMsg);
|
||||
|
||||
builder.setThread(newThread);
|
||||
// Store weak reference to thread in channel
|
||||
channel->addReplyThread(newThread);
|
||||
foundMessage = otherMsg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundMessage)
|
||||
{
|
||||
// We didn't find the reply root message in the otherLoaded messages
|
||||
// which are typically the already-parsed recent messages from the
|
||||
// Recent Messages API. We could have a really old message that
|
||||
// still exists being replied to, so check for that here.
|
||||
foundMessage = channel->findMessage(replyID);
|
||||
}
|
||||
|
||||
if (foundMessage)
|
||||
{
|
||||
std::shared_ptr<MessageThread> newThread =
|
||||
std::make_shared<MessageThread>(foundMessage);
|
||||
|
||||
builder.setThread(newThread);
|
||||
// Store weak reference to thread in channel
|
||||
channel->addReplyThread(newThread);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user