2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 14:45:14 +00:00

Don't replace local with server last message.

This commit is contained in:
John Preston
2020-02-19 17:49:49 +04:00
parent 32d93e2651
commit c04f3a7048
3 changed files with 19 additions and 34 deletions

View File

@@ -1937,8 +1937,8 @@ void History::setFolder(
not_null<Data::Folder*> folder,
HistoryItem *folderDialogItem) {
setFolderPointer(folder);
if (folderDialogItem && _lastMessage != folderDialogItem) {
setLastMessage(folderDialogItem);
if (folderDialogItem) {
setLastServerMessage(folderDialogItem);
}
}
@@ -2369,16 +2369,19 @@ void History::clearSharedMedia() {
//}
}
void History::setLastServerMessage(HistoryItem *item) {
if (_lastMessage
&& *_lastMessage
&& !IsServerMsgId((*_lastMessage)->id)
&& (!item || (*_lastMessage)->date() > item->date())) {
return;
}
setLastMessage(item);
}
void History::setLastMessage(HistoryItem *item) {
if (_lastMessage) {
if (*_lastMessage == item) {
return;
} else if (*_lastMessage
&& item
&& !IsServerMsgId((*_lastMessage)->id)
&& (*_lastMessage)->date() > item->date()) {
return;
}
if (_lastMessage && *_lastMessage == item) {
return;
}
_lastMessage = item;
if (peer->migrateTo()) {
@@ -2766,12 +2769,12 @@ void History::applyDialogTopMessage(MsgId topMessageId) {
channelId(),
topMessageId);
if (const auto item = owner().message(itemId)) {
setLastMessage(item);
setLastServerMessage(item);
} else {
setLastMessage(nullptr);
setLastServerMessage(nullptr);
}
} else {
setLastMessage(nullptr);
setLastServerMessage(nullptr);
}
if (clearUnreadOnClientSide()) {
setUnreadCount(0);
@@ -3167,7 +3170,7 @@ void History::clear(ClearType type) {
setUnreadCount(0);
}
if (type == ClearType::DeleteChat) {
setLastMessage(nullptr);
setLastServerMessage(nullptr);
} else if (_lastMessage && *_lastMessage) {
if (IsServerMsgId((*_lastMessage)->id)) {
(*_lastMessage)->applyEditionToHistoryCleared();