| 176 | } |
| 177 | |
| 178 | void Histories::readInbox(not_null<History*> history) { |
| 179 | DEBUG_LOG(("Reading: readInbox called.")); |
| 180 | if (history->lastServerMessageKnown()) { |
| 181 | const auto last = history->lastServerMessage(); |
| 182 | DEBUG_LOG(("Reading: last known, reading till %1." |
| 183 | ).arg(last ? last->id.bare : 0)); |
| 184 | readInboxTill(history, last ? last->id : 0); |
| 185 | return; |
| 186 | } else if (history->loadedAtBottom()) { |
| 187 | if (const auto lastId = history->maxMsgId()) { |
| 188 | DEBUG_LOG(("Reading: loaded at bottom, maxMsgId %1." |
| 189 | ).arg(lastId.bare)); |
| 190 | readInboxTill(history, lastId); |
| 191 | return; |
| 192 | } else if (history->loadedAtTop()) { |
| 193 | DEBUG_LOG(("Reading: loaded at bottom, loaded at top.")); |
| 194 | readInboxTill(history, 0); |
| 195 | return; |
| 196 | } |
| 197 | DEBUG_LOG(("Reading: loaded at bottom, but requesting entry.")); |
| 198 | } |
| 199 | requestDialogEntry(history, [=] { |
| 200 | Expects(history->lastServerMessageKnown()); |
| 201 | |
| 202 | const auto last = history->lastServerMessage(); |
| 203 | DEBUG_LOG(("Reading: got entry, reading till %1." |
| 204 | ).arg(last ? last->id.bare : 0)); |
| 205 | readInboxTill(history, last ? last->id : 0); |
| 206 | }); |
| 207 | } |
| 208 | |
| 209 | void Histories::readInboxTill(not_null<HistoryItem*> item) { |
| 210 | const auto history = item->history(); |
no test coverage detected