Don't expect itemId from shareContact.

This commit is contained in:
John Preston
2023-09-05 19:28:52 +04:00
parent 191f832e52
commit 8adbbe6885
3 changed files with 46 additions and 57 deletions

View File

@@ -645,40 +645,10 @@ void AttachWebView::botSharePhone(Fn<void(bool shared)> callback) {
}
auto action = Api::SendAction(history);
action.clearDraft = false;
const auto id = history->session().api().shareContact(
history->session().api().shareContact(
_bot->session().user(),
action);
const auto owner = &_bot->owner();
const auto lifetime = std::make_shared<rpl::lifetime>();
const auto check = [=] {
const auto item = id ? owner->message(id) : nullptr;
if (!item || item->hasFailed()) {
lifetime->destroy();
callback(false);
}
};
_bot->session().changes().historyUpdates(
history,
Data::HistoryUpdate::Flag::ClientSideMessages
) | rpl::start_with_next(check, *lifetime);
owner->itemRemoved(
) | rpl::start_with_next([=](not_null<const HistoryItem*> item) {
if (item->fullId() == id) {
check();
}
}, *lifetime);
owner->itemIdChanged(
) | rpl::start_with_next([=](const Data::Session::IdChange &change) {
if (FullMsgId(change.newId.peer, change.oldId) == id) {
lifetime->destroy();
callback(true);
}
}, *lifetime);
check();
action,
std::move(callback));
}
void AttachWebView::botInvokeCustomMethod(