From b83b403b7581d7c691f367cf7cc9e2180616be5c Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 12 Jul 2024 17:00:16 +0200 Subject: [PATCH] Pass correct peer to venue search. --- .../chat_helpers/chat_helpers.style | 35 ++++++++----------- .../inline_bots/bot_attach_web_view.cpp | 1 + .../ui/controls/location_picker.cpp | 7 ++-- .../SourceFiles/ui/controls/location_picker.h | 2 ++ 4 files changed, 21 insertions(+), 24 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/chat_helpers.style b/Telegram/SourceFiles/chat_helpers/chat_helpers.style index d31d2919a..a40d1e0ad 100644 --- a/Telegram/SourceFiles/chat_helpers/chat_helpers.style +++ b/Telegram/SourceFiles/chat_helpers/chat_helpers.style @@ -1428,21 +1428,6 @@ pickLocationWindow: size(364px, 680px); pickLocationMapHeight: 220px; pickLocationCollapsedHeight: 92px; pickLocationRowHeight: 52px; -pickLocationVenue: PeerListItem(defaultPeerListItem) { - height: pickLocationRowHeight; - photoSize: 42px; - photoPosition: point(18px, 5px); - namePosition: point(70px, 9px); - statusPosition: point(70px, 29px); - button: OutlineButton(defaultPeerListButton) { - textBg: contactsBg; - textBgOver: contactsBgOver; - ripple: defaultRippleAnimation; - } - statusFg: contactsStatusFg; - statusFgOver: contactsStatusFgOver; - statusFgActive: contactsStatusFgOnline; -} pickLocationButton: FlatButton { height: pickLocationRowHeight; bgColor: contactsBg; @@ -1451,25 +1436,33 @@ pickLocationButton: FlatButton { } pickLocationButtonText: FlatLabel(defaultFlatLabel) { minWidth: 128px; + maxHeight: 20px; style: semiboldTextStyle; textFg: windowBoldFg; } pickLocationButtonStatus: FlatLabel(defaultFlatLabel) { minWidth: 128px; + maxHeight: 20px; textFg: windowSubTextFg; } pickLocationButtonSkip: 6px; pickLocationSendIcon: icon{{ "chat/filled_location", windowFgActive }}; pickLocationVenueItem: PeerListItem(defaultPeerListItem) { - button: OutlineButton(defaultPeerListButton) { - font: normalFont; - padding: margins(11px, 5px, 11px, 5px); - } - height: 52px; + height: pickLocationRowHeight; + photoSize: 42px; photoPosition: point(18px, 5px); namePosition: point(70px, 7px); statusPosition: point(70px, 27px); - photoSize: 42px; + button: OutlineButton(defaultPeerListButton) { + textBg: contactsBg; + textBgOver: contactsBgOver; + font: normalFont; + padding: margins(11px, 5px, 11px, 5px); + ripple: defaultRippleAnimation; + } + statusFg: contactsStatusFg; + statusFgOver: contactsStatusFgOver; + statusFgActive: contactsStatusFgOnline; } pickLocationVenueList: PeerList(defaultPeerList) { item: pickLocationVenueItem; diff --git a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp index d52e13b82..4dbd94e1d 100644 --- a/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp +++ b/Telegram/SourceFiles/inline_bots/bot_attach_web_view.cpp @@ -1822,6 +1822,7 @@ void ChooseAndSendLocation( Ui::LocationPicker::Show({ .parent = controller->widget(), .config = config, + .recipient = action.history->peer, .session = &controller->session(), .callback = crl::guard(controller, callback), .quit = [] { Shortcuts::Launch(Shortcuts::Command::Quit); }, diff --git a/Telegram/SourceFiles/ui/controls/location_picker.cpp b/Telegram/SourceFiles/ui/controls/location_picker.cpp index ed9d84f7a..5438d00d4 100644 --- a/Telegram/SourceFiles/ui/controls/location_picker.cpp +++ b/Telegram/SourceFiles/ui/controls/location_picker.cpp @@ -409,7 +409,7 @@ void VenuesController::rowPaintIcon( st::pickLocationButton); const auto raw = result.data(); - const auto st = &st::pickLocationVenue; + const auto st = &st::pickLocationVenueItem; const auto icon = CreateChild(raw); icon->setGeometry( st->photoPosition.x(), @@ -628,7 +628,8 @@ LocationPicker::LocationPicker(Descriptor &&descriptor) venuesRequest(*_venuesSearchLocation, *_venuesSearchQuery); }) -, _api(&_session->mtp()) { +, _api(&_session->mtp()) +, _venueRecipient(descriptor.recipient) { std::move( descriptor.closeRequests ) | rpl::start_with_next([=] { @@ -1002,7 +1003,7 @@ void LocationPicker::venuesSendRequest() { _venuesRequestId = _api.request(MTPmessages_GetInlineBotResults( MTP_flags(MTPmessages_GetInlineBotResults::Flag::f_geo_point), _venuesBot->inputUser, - MTP_inputPeerEmpty(), + (_venueRecipient ? _venueRecipient->input : MTP_inputPeerEmpty()), MTP_inputGeoPoint( MTP_flags(0), MTP_double(_venuesRequestLocation.point.x()), diff --git a/Telegram/SourceFiles/ui/controls/location_picker.h b/Telegram/SourceFiles/ui/controls/location_picker.h index 6014bd06b..756e6b162 100644 --- a/Telegram/SourceFiles/ui/controls/location_picker.h +++ b/Telegram/SourceFiles/ui/controls/location_picker.h @@ -80,6 +80,7 @@ public: struct Descriptor { RpWidget *parent = nullptr; LocationPickerConfig config; + PeerData *recipient = nullptr; not_null session; Fn callback; Fn quit; @@ -145,6 +146,7 @@ private: std::optional _venuesSearchQuery; base::Timer _venuesSearchDebounceTimer; MTP::Sender _api; + PeerData *_venueRecipient = nullptr; UserData *_venuesBot = nullptr; mtpRequestId _venuesBotRequestId = 0; mtpRequestId _venuesRequestId = 0;