2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Search through Histories.

This commit is contained in:
John Preston
2020-02-21 16:57:06 +04:00
parent 6f672ecdc3
commit ec7a2dce2f
6 changed files with 168 additions and 110 deletions

View File

@@ -549,7 +549,8 @@ int Histories::sendRequest(
Expects(type != RequestType::None);
auto &state = _states[history];
const auto id = ++state.autoincrement;
const auto id = ++_requestAutoincrement;
_historyByRequest.emplace(id, history);
if (type == RequestType::History && postponeHistoryRequest(state)) {
state.postponed.emplace(
id,
@@ -593,19 +594,24 @@ void Histories::checkPostponed(not_null<History*> history, int id) {
finishSentRequest(history, state, id);
}
void Histories::cancelRequest(not_null<History*> history, int id) {
const auto state = lookup(history);
void Histories::cancelRequest(int id) {
const auto history = _historyByRequest.take(id);
if (!history) {
return;
}
const auto state = lookup(*history);
if (!state) {
return;
}
state->postponed.remove(id);
finishSentRequest(history, state, id);
finishSentRequest(*history, state, id);
}
void Histories::finishSentRequest(
not_null<History*> history,
not_null<State*> state,
int id) {
_historyByRequest.remove(id);
state->sent.remove(id);
if (!state->postponed.empty() && !postponeHistoryRequest(*state)) {
for (auto &[id, postponed] : base::take(state->postponed)) {
@@ -626,6 +632,7 @@ void Histories::finishSentRequest(
history,
std::move(i->second));
Assert(ok);
_dialogRequests.erase(i);
state->postponedRequestEntry = false;
}
checkEmptyState(history);