Fix draft clearing on message send.

Regression was introduced in caef7dde24.
This commit is contained in:
John Preston 2019-08-30 13:17:18 +03:00
parent f199205592
commit 5758f756c9
6 changed files with 7 additions and 4 deletions

View File

@ -28,7 +28,7 @@ struct SendAction {
not_null<History*> history; not_null<History*> history;
SendOptions options; SendOptions options;
MsgId replyTo = 0; MsgId replyTo = 0;
bool clearDraft = false; bool clearDraft = true;
bool generateLocal = true; bool generateLocal = true;
}; };

View File

@ -114,6 +114,7 @@ void activateBotCommand(
Ui::show(Box<ConfirmBox>(tr::lng_bot_share_phone(tr::now), tr::lng_bot_share_phone_confirm(tr::now), [=] { Ui::show(Box<ConfirmBox>(tr::lng_bot_share_phone(tr::now), tr::lng_bot_share_phone_confirm(tr::now), [=] {
Ui::showPeerHistory(history, ShowAtTheEndMsgId); Ui::showPeerHistory(history, ShowAtTheEndMsgId);
auto action = Api::SendAction(history); auto action = Api::SendAction(history);
action.clearDraft = false;
action.replyTo = msgId; action.replyTo = msgId;
history->session().api().shareContact( history->session().api().shareContact(
history->session().user(), history->session().user(),

View File

@ -5547,7 +5547,6 @@ void HistoryWidget::sendInlineResult(
} }
auto action = Api::SendAction(_history); auto action = Api::SendAction(_history);
action.clearDraft = true;
action.replyTo = replyToId(); action.replyTo = replyToId();
action.generateLocal = true; action.generateLocal = true;
session().api().sendInlineResult(bot, result, action); session().api().sendInlineResult(bot, result, action);

View File

@ -512,7 +512,6 @@ void ScheduledWidget::sendInlineResult(
not_null<UserData*> bot, not_null<UserData*> bot,
Api::SendOptions options) { Api::SendOptions options) {
auto action = Api::SendAction(_history); auto action = Api::SendAction(_history);
action.clearDraft = true;
//action.replyTo = replyToId(); //action.replyTo = replyToId();
action.options = options; action.options = options;
action.generateLocal = true; action.generateLocal = true;

View File

@ -604,7 +604,7 @@ QString InterpretSendPath(const QString &path) {
return "App Error: Could not find channel with id: " + QString::number(peerToChannel(toId)); return "App Error: Could not find channel with id: " + QString::number(peerToChannel(toId));
} }
Ui::showPeerHistory(history, ShowAtUnreadMsgId); Ui::showPeerHistory(history, ShowAtUnreadMsgId);
Auth().api().sendFiles( history->session().api().sendFiles(
Storage::PrepareMediaList(QStringList(filePath), st::sendMediaPreviewSize), Storage::PrepareMediaList(QStringList(filePath), st::sendMediaPreviewSize),
SendMediaType::File, SendMediaType::File,
{ caption }, { caption },

View File

@ -669,6 +669,7 @@ void PeerMenuShareContactBox(
return; return;
} else if (peer->isSelf()) { } else if (peer->isSelf()) {
auto action = Api::SendAction(peer->owner().history(peer)); auto action = Api::SendAction(peer->owner().history(peer));
action.clearDraft = false;
user->session().api().shareContact(user, action); user->session().api().shareContact(user, action);
Ui::Toast::Show(tr::lng_share_done(tr::now)); Ui::Toast::Show(tr::lng_share_done(tr::now));
if (auto strong = *weak) { if (auto strong = *weak) {
@ -686,6 +687,7 @@ void PeerMenuShareContactBox(
const auto history = peer->owner().history(peer); const auto history = peer->owner().history(peer);
Ui::showPeerHistory(history, ShowAtTheEndMsgId); Ui::showPeerHistory(history, ShowAtTheEndMsgId);
auto action = Api::SendAction(history); auto action = Api::SendAction(history);
action.clearDraft = false;
user->session().api().shareContact(user, action); user->session().api().shareContact(user, action);
}), LayerOption::KeepOther); }), LayerOption::KeepOther);
}; };
@ -711,6 +713,7 @@ void PeerMenuCreatePoll(not_null<PeerData*> peer) {
return; return;
} }
auto action = Api::SendAction(peer->owner().history(peer)); auto action = Api::SendAction(peer->owner().history(peer));
action.clearDraft = false;
action.options = result.options; action.options = result.options;
if (const auto id = App::main()->currentReplyToIdFor(action.history)) { if (const auto id = App::main()->currentReplyToIdFor(action.history)) {
action.replyTo = id; action.replyTo = id;
@ -827,6 +830,7 @@ QPointer<Ui::RpWidget> ShowForwardMessagesBox(
if (!items.empty()) { if (!items.empty()) {
const auto api = &peer->session().api(); const auto api = &peer->session().api();
auto action = Api::SendAction(peer->owner().history(peer)); auto action = Api::SendAction(peer->owner().history(peer));
action.clearDraft = false;
action.generateLocal = false; action.generateLocal = false;
api->forwardMessages(std::move(items), action, [] { api->forwardMessages(std::move(items), action, [] {
Ui::Toast::Show(tr::lng_share_done(tr::now)); Ui::Toast::Show(tr::lng_share_done(tr::now));