From fccae52654cb6db77e55ebecb8b832bbfdeadd85 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 11 Jun 2016 22:44:55 +0300 Subject: [PATCH] Workaround for a server-side bug with dates of migrate/invite. Fixes the appearing of duplicated supergroup migrate message together with not needed client side joined/invited message. --- Telegram/SourceFiles/history.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/history.cpp b/Telegram/SourceFiles/history.cpp index 48e6b190c..161a2fdbc 100644 --- a/Telegram/SourceFiles/history.cpp +++ b/Telegram/SourceFiles/history.cpp @@ -398,12 +398,14 @@ HistoryJoined *ChannelHistory::insertJoinedMessage(bool unread) { HistoryItem *item = block->items.at(--itemIndex); HistoryItemType type = item->type(); if (type == HistoryItemMsg) { + // Due to a server bug sometimes inviteDate is less (before) than the + // first message in the megagroup (message about migration), let us + // ignore that and think, that the inviteDate is always greater-or-equal. + if (item->isGroupMigrate() && peer->isMegagroup() && peer->migrateFrom()) { + peer->asChannel()->mgInfo->joinedMessageFound = true; + return nullptr; + } if (item->date <= inviteDate) { - if (peer->isMegagroup() && peer->migrateFrom() && item->isGroupMigrate()) { - peer->asChannel()->mgInfo->joinedMessageFound = true; - return nullptr; - } - ++itemIndex; _joinedMessage = HistoryJoined::create(this, inviteDate, inviter, flags); addNewInTheMiddle(_joinedMessage, blockIndex, itemIndex);