2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Cloud stored drafts started.

This commit is contained in:
John Preston
2016-05-31 12:46:31 +03:00
parent 7f353d9b1a
commit 916068447a
18 changed files with 230 additions and 93 deletions

View File

@@ -474,10 +474,18 @@ History *Histories::find(const PeerId &peerId) {
History *Histories::findOrInsert(const PeerId &peerId, int32 unreadCount, int32 maxInboxRead, int32 maxOutboxRead) {
auto i = map.constFind(peerId);
if (i == map.cend()) {
i = map.insert(peerId, peerIsChannel(peerId) ? static_cast<History*>(new ChannelHistory(peerId)) : (new History(peerId)));
i.value()->setUnreadCount(unreadCount);
i.value()->inboxReadBefore = maxInboxRead + 1;
i.value()->outboxReadBefore = maxOutboxRead + 1;
auto history = peerIsChannel(peerId) ? static_cast<History*>(new ChannelHistory(peerId)) : (new History(peerId));
i = map.insert(peerId, history);
history->setUnreadCount(unreadCount);
history->inboxReadBefore = maxInboxRead + 1;
history->outboxReadBefore = maxOutboxRead + 1;
} else {
auto history = i.value();
if (unreadCount >= history->unreadCount()) {
history->setUnreadCount(unreadCount);
history->inboxReadBefore = maxInboxRead + 1;
}
accumulate_max(history->outboxReadBefore, maxOutboxRead + 1);
}
return i.value();
}