Added ability to provide text with tags when send existing document.

This commit is contained in:
23rd 2024-08-22 17:07:06 +03:00
parent 679350e23d
commit ec7fbb8952
11 changed files with 47 additions and 26 deletions

View file

@ -457,7 +457,8 @@ void GifsListWidget::mouseReleaseEvent(QMouseEvent *e) {
void GifsListWidget::selectInlineResult( void GifsListWidget::selectInlineResult(
int index, int index,
Api::SendOptions options, Api::SendOptions options,
bool forceSend) { bool forceSend,
TextWithTags caption) {
const auto item = _mosaic.maybeItemAt(index); const auto item = _mosaic.maybeItemAt(index);
if (!item) { if (!item) {
return; return;
@ -498,6 +499,7 @@ void GifsListWidget::selectInlineResult(
.document = document, .document = document,
.options = options, .options = options,
.messageSendingFrom = messageSendingFrom(), .messageSendingFrom = messageSendingFrom(),
.caption = std::move(caption),
}); });
} else if (!preview.usingThumbnail()) { } else if (!preview.usingThumbnail()) {
if (preview.loading()) { if (preview.loading()) {

View file

@ -172,7 +172,8 @@ private:
void selectInlineResult( void selectInlineResult(
int index, int index,
Api::SendOptions options, Api::SendOptions options,
bool forceSend = false); bool forceSend = false,
TextWithTags caption = {});
const std::shared_ptr<Show> _show; const std::shared_ptr<Show> _show;
std::unique_ptr<Ui::TabbedSearch> _search; std::unique_ptr<Ui::TabbedSearch> _search;

View file

@ -62,6 +62,7 @@ struct FileChosen {
not_null<DocumentData*> document; not_null<DocumentData*> document;
Api::SendOptions options; Api::SendOptions options;
Ui::MessageSendingAnimationFrom messageSendingFrom; Ui::MessageSendingAnimationFrom messageSendingFrom;
TextWithTags caption;
}; };
struct PhotoChosen { struct PhotoChosen {

View file

@ -1201,7 +1201,13 @@ void HistoryWidget::initTabbedSelector() {
controller()->sendingAnimation().appendSending( controller()->sendingAnimation().appendSending(
data.messageSendingFrom); data.messageSendingFrom);
const auto localId = data.messageSendingFrom.localId; const auto localId = data.messageSendingFrom.localId;
sendExistingDocument(data.document, data.options, localId); auto messageToSend = Api::MessageToSend(
prepareSendAction(data.options));
messageToSend.textWithTags = base::take(data.caption);
sendExistingDocument(
data.document,
std::move(messageToSend),
localId);
} }
}, lifetime()); }, lifetime());
@ -7458,7 +7464,7 @@ void HistoryWidget::requestMessageData(MsgId msgId) {
bool HistoryWidget::sendExistingDocument( bool HistoryWidget::sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options, Api::MessageToSend messageToSend,
std::optional<MsgId> localId) { std::optional<MsgId> localId) {
const auto error = _peer const auto error = _peer
? Data::RestrictionError(_peer, ChatRestriction::SendStickers) ? Data::RestrictionError(_peer, ChatRestriction::SendStickers)
@ -7474,7 +7480,7 @@ bool HistoryWidget::sendExistingDocument(
} }
Api::SendExistingDocument( Api::SendExistingDocument(
Api::MessageToSend(prepareSendAction(options)), std::move(messageToSend),
document, document,
localId); localId);

View file

@ -37,6 +37,7 @@ struct Details;
} // namespace SendMenu } // namespace SendMenu
namespace Api { namespace Api {
struct MessageToSend;
struct SendOptions; struct SendOptions;
struct SendAction; struct SendAction;
} // namespace Api } // namespace Api
@ -273,7 +274,7 @@ public:
[[nodiscard]] SendMenu::Details saveMenuDetails() const; [[nodiscard]] SendMenu::Details saveMenuDetails() const;
bool sendExistingDocument( bool sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options, Api::MessageToSend messageToSend,
std::optional<MsgId> localId = std::nullopt); std::optional<MsgId> localId = std::nullopt);
bool sendExistingPhoto( bool sendExistingPhoto(
not_null<PhotoData*> photo, not_null<PhotoData*> photo,

View file

@ -760,8 +760,13 @@ void RepliesWidget::setupComposeControls() {
controller()->hideLayer(anim::type::normal); controller()->hideLayer(anim::type::normal);
controller()->sendingAnimation().appendSending( controller()->sendingAnimation().appendSending(
data.messageSendingFrom); data.messageSendingFrom);
const auto localId = data.messageSendingFrom.localId; auto messageToSend = Api::MessageToSend(
sendExistingDocument(data.document, data.options, localId); prepareSendAction(data.options));
messageToSend.textWithTags = base::take(data.caption);
sendExistingDocument(
data.document,
std::move(messageToSend),
data.messageSendingFrom.localId);
}, lifetime()); }, lifetime());
_composeControls->photoChosen( _composeControls->photoChosen(
@ -1327,7 +1332,7 @@ void RepliesWidget::refreshJoinGroupButton() {
bool RepliesWidget::sendExistingDocument( bool RepliesWidget::sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options, Api::MessageToSend messageToSend,
std::optional<MsgId> localId) { std::optional<MsgId> localId) {
const auto error = Data::RestrictionError( const auto error = Data::RestrictionError(
_history->peer, _history->peer,
@ -1341,7 +1346,7 @@ bool RepliesWidget::sendExistingDocument(
} }
Api::SendExistingDocument( Api::SendExistingDocument(
Api::MessageToSend(prepareSendAction(options)), std::move(messageToSend),
document, document,
localId); localId);

View file

@ -23,6 +23,7 @@ struct Details;
} // namespace SendMenu } // namespace SendMenu
namespace Api { namespace Api {
struct MessageToSend;
struct SendOptions; struct SendOptions;
struct SendAction; struct SendAction;
} // namespace Api } // namespace Api
@ -303,7 +304,7 @@ private:
bool sendExistingDocument( bool sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options, Api::MessageToSend messageToSend,
std::optional<MsgId> localId); std::optional<MsgId> localId);
void sendExistingPhoto(not_null<PhotoData*> photo); void sendExistingPhoto(not_null<PhotoData*> photo);
bool sendExistingPhoto( bool sendExistingPhoto(

View file

@ -342,7 +342,10 @@ void ScheduledWidget::setupComposeControls() {
controller()->hideLayer(anim::type::normal); controller()->hideLayer(anim::type::normal);
const auto document = data.document; const auto document = data.document;
const auto callback = crl::guard(this, [=](Api::SendOptions options) { const auto callback = crl::guard(this, [=](Api::SendOptions options) {
sendExistingDocument(document, options); auto messageToSend = Api::MessageToSend(
prepareSendAction(options));
messageToSend.textWithTags = data.caption;
sendExistingDocument(document, std::move(messageToSend));
}); });
controller()->show( controller()->show(
PrepareScheduleBox(this, _show, sendMenuDetails(), callback)); PrepareScheduleBox(this, _show, sendMenuDetails(), callback));
@ -815,7 +818,7 @@ void ScheduledWidget::edit(
bool ScheduledWidget::sendExistingDocument( bool ScheduledWidget::sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options) { Api::MessageToSend messageToSend) {
const auto error = Data::RestrictionError( const auto error = Data::RestrictionError(
_history->peer, _history->peer,
ChatRestriction::SendStickers); ChatRestriction::SendStickers);
@ -826,9 +829,7 @@ bool ScheduledWidget::sendExistingDocument(
return false; return false;
} }
Api::SendExistingDocument( Api::SendExistingDocument(std::move(messageToSend), document);
Api::MessageToSend(prepareSendAction(options)),
document);
_composeControls->hidePanelsAnimated(); _composeControls->hidePanelsAnimated();
_composeControls->focus(); _composeControls->focus();

View file

@ -26,6 +26,7 @@ struct Details;
} // namespace SendMenu } // namespace SendMenu
namespace Api { namespace Api {
struct MessageToSend;
struct SendOptions; struct SendOptions;
struct SendAction; struct SendAction;
} // namespace Api } // namespace Api
@ -253,7 +254,7 @@ private:
bool sendExistingDocument( bool sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options); Api::MessageToSend messageToSend);
void sendExistingPhoto(not_null<PhotoData*> photo); void sendExistingPhoto(not_null<PhotoData*> photo);
bool sendExistingPhoto( bool sendExistingPhoto(
not_null<PhotoData*> photo, not_null<PhotoData*> photo,

View file

@ -252,7 +252,7 @@ void ReplyArea::sendVoice(VoiceToSend &&data) {
bool ReplyArea::sendExistingDocument( bool ReplyArea::sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options, Api::MessageToSend messageToSend,
std::optional<MsgId> localId) { std::optional<MsgId> localId) {
Expects(_data.peer != nullptr); Expects(_data.peer != nullptr);
@ -268,10 +268,7 @@ bool ReplyArea::sendExistingDocument(
return false; return false;
} }
Api::SendExistingDocument( Api::SendExistingDocument(std::move(messageToSend), document, localId);
Api::MessageToSend(prepareSendAction(options)),
document,
localId);
_controls->cancelReplyMessage(); _controls->cancelReplyMessage();
finishSending(); finishSending();
@ -633,8 +630,13 @@ void ReplyArea::initActions() {
_controls->fileChosen( _controls->fileChosen(
) | rpl::start_with_next([=](ChatHelpers::FileChosen data) { ) | rpl::start_with_next([=](ChatHelpers::FileChosen data) {
_controller->uiShow()->hideLayer(); _controller->uiShow()->hideLayer();
const auto localId = data.messageSendingFrom.localId; auto messageToSend = Api::MessageToSend(
sendExistingDocument(data.document, data.options, localId); prepareSendAction(data.options));
messageToSend.textWithTags = base::take(data.caption);
sendExistingDocument(
data.document,
std::move(messageToSend),
data.messageSendingFrom.localId);
}, _lifetime); }, _lifetime);
_controls->photoChosen( _controls->photoChosen(

View file

@ -13,9 +13,9 @@ class History;
enum class SendMediaType; enum class SendMediaType;
namespace Api { namespace Api {
struct MessageToSend;
struct SendAction; struct SendAction;
struct SendOptions; struct SendOptions;
struct MessageToSend;
} // namespace Api } // namespace Api
namespace Data { namespace Data {
@ -120,7 +120,7 @@ private:
bool sendExistingDocument( bool sendExistingDocument(
not_null<DocumentData*> document, not_null<DocumentData*> document,
Api::SendOptions options, Api::MessageToSend messageToSend,
std::optional<MsgId> localId); std::optional<MsgId> localId);
void sendExistingPhoto(not_null<PhotoData*> photo); void sendExistingPhoto(not_null<PhotoData*> photo);
bool sendExistingPhoto( bool sendExistingPhoto(