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

Use server time in dialogs list sorting.

This way it won't mess up when you change your local time.
This commit is contained in:
John Preston
2018-07-31 17:34:14 +03:00
parent f68cefbdc1
commit 9972f7b90e
10 changed files with 47 additions and 42 deletions

View File

@@ -1827,14 +1827,11 @@ std::shared_ptr<AdminLog::LocalIdManager> History::adminLogIdManager() {
return result;
}
QDateTime History::adjustChatListDate() const {
const auto result = chatsListDate();
TimeId History::adjustChatListTimeId() const {
const auto result = chatsListTimeId();
if (const auto draft = cloudDraft()) {
if (!Data::draftIsNull(draft)) {
const auto draftResult = ParseDateTime(draft->date);
if (draftResult > result) {
return draftResult;
}
return std::max(result, draft->date);
}
}
return result;
@@ -2182,7 +2179,7 @@ void History::setLastMessage(HistoryItem *item) {
if (const auto feed = peer->feed()) {
feed->updateLastMessage(item);
}
setChatsListDate(ItemDateTime(item));
setChatsListTimeId(item->date());
} else if (!_lastMessage || *_lastMessage) {
_lastMessage = nullptr;
updateChatListEntry();
@@ -2500,8 +2497,8 @@ HistoryService *History::insertJoinedMessage(bool unread) {
inviter,
flags);
addNewInTheMiddle(_joinedMessage, blockIndex, itemIndex);
const auto lastDate = chatsListDate();
if (lastDate.isNull() || ParseDateTime(inviteDate) >= lastDate) {
const auto lastDate = chatsListTimeId();
if (!lastDate || inviteDate >= lastDate) {
setLastMessage(_joinedMessage);
if (unread) {
newItemAdded(_joinedMessage);

View File

@@ -445,7 +445,7 @@ private:
not_null<Element*> view);
void removeNotification(not_null<HistoryItem*> item);
QDateTime adjustChatListDate() const override;
TimeId adjustChatListTimeId() const override;
void changedInChatListHook(Dialogs::Mode list, bool added) override;
void changedChatListPinHook() override;