mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-02-24 17:26:58 +00:00
Fix 'reading' of an empty history.
This commit is contained in:
parent
388173f0ad
commit
a3f19c073b
@ -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;
|
||||
|
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user