diff --git a/Telegram/SourceFiles/api/api_updates.cpp b/Telegram/SourceFiles/api/api_updates.cpp index f96fa0ec0..c36bd409b 100644 --- a/Telegram/SourceFiles/api/api_updates.cpp +++ b/Telegram/SourceFiles/api/api_updates.cpp @@ -278,11 +278,25 @@ void Updates::checkLastUpdate(bool afterSleep) { void Updates::feedUpdateVector( const MTPVector &updates, bool skipMessageIds) { - for (const auto &update : updates.v) { - if (skipMessageIds && update.type() == mtpc_updateMessageID) { + auto list = updates.v; + const auto needsSorting = ranges::contains( + list, + mtpc_updateGroupCallParticipants, + &MTPUpdate::type); + if (needsSorting) { + ranges::stable_sort(list, std::less<>(), [](const MTPUpdate &entry) { + if (entry.type() == mtpc_updateGroupCallParticipants) { + return 0; + } else { + return 1; + } + }); + } + for (const auto &entry : std::as_const(list)) { + if (skipMessageIds && entry.type() == mtpc_updateMessageID) { continue; } - feedUpdate(update); + feedUpdate(entry); } session().data().sendHistoryChangeNotifications(); }