2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Unify message sending, track forum topic icons.

This commit is contained in:
John Preston
2022-09-27 20:52:35 +04:00
parent 3b3792ef75
commit 9f652b0d3f
29 changed files with 477 additions and 259 deletions

View File

@@ -841,6 +841,39 @@ int Histories::sendRequest(
return id;
}
int Histories::sendPreparedMessage(
not_null<History*> history,
MsgId replyTo,
uint64 randomId,
PreparedMessage message,
Fn<void(const MTPUpdates&, const MTP::Response&)> done,
Fn<void(const MTP::Error&, const MTP::Response&)> fail) {
return v::match(message, [&](const auto &request) {
const auto type = RequestType::Send;
return sendRequest(history, type, [=](Fn<void()> finish) {
const auto session = &_owner->session();
const auto api = &session->api();
history->sendRequestId = api->request(
base::duplicate(request)
).done([=](
const MTPUpdates &result,
const MTP::Response &response) {
api->applyUpdates(result, randomId);
done(result, response);
finish();
}).fail([=](
const MTP::Error &error,
const MTP::Response &response) {
fail(error, response);
finish();
}).afterRequest(
history->sendRequestId
).send();
return history->sendRequestId;
});
});
}
void Histories::checkPostponed(not_null<History*> history, int id) {
if (const auto state = lookup(history)) {
finishSentRequest(history, state, id);