Fix dice unqouted forward to opened chat

This commit is contained in:
Eric Kotato 2021-03-29 04:16:22 +03:00
parent 1488e02ac5
commit 0e0b99e40c
3 changed files with 15 additions and 13 deletions

View file

@ -229,7 +229,10 @@ void SendExistingPhoto(
forwarding);
}
bool SendDice(Api::MessageToSend &message, Fn<void()> doneCallback) {
bool SendDice(
Api::MessageToSend &message,
Fn<void()> doneCallback,
bool forwarding) {
const auto full = message.textWithTags.text.midRef(0).trimmed();
auto length = 0;
if (!Ui::Emoji::Find(full.data(), full.data() + full.size(), &length)
@ -350,7 +353,9 @@ bool SendDice(Api::MessageToSend &message, Fn<void()> doneCallback) {
).send();
return history->sendRequestId;
});
api->finishForwarding(message.action);
if (!forwarding) {
api->finishForwarding(message.action);
}
return true;
}

View file

@ -37,7 +37,10 @@ void SendExistingPhoto(
Fn<void()> doneCallback = nullptr,
bool forwarding = false);
bool SendDice(Api::MessageToSend &message, Fn<void()> doneCallback = nullptr);
bool SendDice(
Api::MessageToSend &message,
Fn<void()> doneCallback = nullptr,
bool forwarding = false);
void FillMessagePostFlags(
const SendAction &action,

View file

@ -4063,20 +4063,15 @@ void ApiWrap::forwardMessagesUnquoted(
}
auto message = ApiWrap::MessageToSend(history);
message.textWithTags = TextWithTags{
dice->emoji(),
TextWithTags::Tags()
};
message.textWithTags.text = dice->emoji();
message.action.options = action.options;
message.action.clearDraft = false;
auto doneCallback = [=] () {
Api::SendDice(message, [=] {
if (shared && !--shared->requestsLeft) {
shared->callback();
}
};
SendDice(message, std::move(doneCallback));
}, true); // forwarding
};
const auto forwardMessageUnquoted = [&] (not_null<HistoryItem *> item) {
@ -4104,8 +4099,7 @@ void ApiWrap::forwardMessagesUnquoted(
if (shared && !--shared->requestsLeft) {
shared->callback();
}
},
true); // forwarding
}, true); // forwarding
};
const auto sendAccumulated = [&] {