From ca548a11d7b6e183444d713768ee7ff5fd59e207 Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 26 Apr 2019 17:23:32 +0400 Subject: [PATCH] Fix assertion violation in History::inboxRead(). --- Telegram/SourceFiles/history/history.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Telegram/SourceFiles/history/history.cpp b/Telegram/SourceFiles/history/history.cpp index 1f93f60f3..bfa188a2f 100644 --- a/Telegram/SourceFiles/history/history.cpp +++ b/Telegram/SourceFiles/history/history.cpp @@ -1495,6 +1495,9 @@ void History::addToSharedMedia( } std::optional History::countUnread(MsgId upTo) const { + if (!folderKnown() || !loadedAtBottom()) { + return std::nullopt; + } auto result = 0; for (auto i = blocks.cend(), e = blocks.cbegin(); i != e;) { --i; @@ -1568,7 +1571,7 @@ void History::inboxRead(MsgId upTo, std::optional stillUnread) { if (unreadCount() > 0 && loadedAtBottom()) { App::main()->historyToDown(this); } - if (stillUnread) { + if (stillUnread.has_value() && folderKnown()) { setUnreadCount(*stillUnread); } else if (const auto still = countUnread(upTo)) { setUnreadCount(*still);