2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-02 23:55:12 +00:00

Remove locally saved empty histories.

This commit is contained in:
John Preston
2019-05-03 15:18:18 +04:00
parent 39b7f307a4
commit 0247e876df
10 changed files with 9 additions and 173 deletions

View File

@@ -189,8 +189,6 @@ void Session::clear() {
base::take(_channelMessages);
_messageByRandomId.clear();
_sentMessagesData.clear();
cSetSavedPeers(SavedPeers());
cSetSavedPeersByTime(SavedPeersByTime());
cSetRecentInlineBots(RecentInlineBots());
cSetRecentStickers(RecentStickerPack());
cSetReportSpamStatuses(ReportSpamStatuses());
@@ -1415,12 +1413,6 @@ void Session::applyDialog(
history->applyDialog(requestFolder, data);
setPinnedFromDialog(history, data.is_pinned());
if (!history->fixedOnTopIndex() && !history->isPinnedDialog()) {
const auto date = history->chatListTimeId();
if (date != 0) {
addSavedPeersAfter(ParseDateTime(date));
}
}
if (const auto from = history->peer->migrateFrom()) {
if (const auto historyFrom = from->owner().historyLoaded(from)) {
App::main()->removeDialog(historyFrom);
@@ -1441,31 +1433,6 @@ void Session::applyDialog(
const auto folder = processFolder(data.vfolder);
folder->applyDialog(data);
setPinnedFromDialog(folder, data.is_pinned());
if (!folder->fixedOnTopIndex() && !folder->isPinnedDialog()) {
const auto date = folder->chatListTimeId();
if (date != 0) {
addSavedPeersAfter(ParseDateTime(date));
}
}
}
void Session::addSavedPeersAfter(const QDateTime &date) {
auto &saved = cRefSavedPeersByTime();
while (!saved.isEmpty() && (date.isNull() || date < saved.lastKey())) {
const auto lastDate = saved.lastKey();
const auto lastPeer = saved.last();
saved.remove(lastDate, lastPeer);
const auto history = session().data().history(lastPeer);
if (!history->chatListTimeId()) {
history->setChatListTimeId(ServerTimeFromParsed(lastDate));
}
}
}
void Session::addAllSavedPeers() {
addSavedPeersAfter(QDateTime());
}
int Session::pinnedChatsCount(Data::Folder *folder) const {