Fix 'reading' of an empty history.

This commit is contained in:
John Preston 2020-02-20 13:37:00 +04:00
parent 388173f0ad
commit a3f19c073b
2 changed files with 7 additions and 3 deletions

View File

@ -131,6 +131,8 @@ void Histories::readInboxTill(
not_null<History*> history,
MsgId tillId,
bool force) {
Expects(IsServerMsgId(tillId) || (!tillId && !force));
if (!history->readInboxTillNeedsRequest(tillId) && !force) {
return;
} else if (!force) {
@ -202,7 +204,9 @@ void Histories::sendReadRequests() {
const auto now = crl::now();
auto next = std::optional<crl::time>();
for (auto &[history, state] : _states) {
if (state.readTill && state.readWhen <= now) {
if (!state.readTill) {
continue;
} else if (state.readWhen <= now) {
sendReadRequest(history, state);
} else if (!next || *next > state.readWhen) {
next = state.readWhen;

View File

@ -1615,13 +1615,13 @@ void History::calculateFirstUnreadMessage() {
}
bool History::readInboxTillNeedsRequest(MsgId tillId) {
Expects(IsServerMsgId(tillId));
Expects(!tillId || IsServerMsgId(tillId));
readClientSideMessages();
if (unreadMark()) {
session().api().changeDialogUnreadMark(this, false);
}
return (_inboxReadBefore.value_or(1) <= tillId);
return IsServerMsgId(tillId) && (_inboxReadBefore.value_or(1) <= tillId);
}
void History::readClientSideMessages() {