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.
This commit is contained in:
John Preston 2016-06-11 22:44:55 +03:00
parent 8e0bab5adc
commit fccae52654
1 changed files with 7 additions and 5 deletions

View File

@ -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);