Pass correct peer to venue search.

This commit is contained in:
John Preston 2024-07-12 17:00:16 +02:00
parent 8aac07b3c0
commit b83b403b75
4 changed files with 21 additions and 24 deletions

View file

@ -1428,21 +1428,6 @@ pickLocationWindow: size(364px, 680px);
pickLocationMapHeight: 220px; pickLocationMapHeight: 220px;
pickLocationCollapsedHeight: 92px; pickLocationCollapsedHeight: 92px;
pickLocationRowHeight: 52px; 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 { pickLocationButton: FlatButton {
height: pickLocationRowHeight; height: pickLocationRowHeight;
bgColor: contactsBg; bgColor: contactsBg;
@ -1451,25 +1436,33 @@ pickLocationButton: FlatButton {
} }
pickLocationButtonText: FlatLabel(defaultFlatLabel) { pickLocationButtonText: FlatLabel(defaultFlatLabel) {
minWidth: 128px; minWidth: 128px;
maxHeight: 20px;
style: semiboldTextStyle; style: semiboldTextStyle;
textFg: windowBoldFg; textFg: windowBoldFg;
} }
pickLocationButtonStatus: FlatLabel(defaultFlatLabel) { pickLocationButtonStatus: FlatLabel(defaultFlatLabel) {
minWidth: 128px; minWidth: 128px;
maxHeight: 20px;
textFg: windowSubTextFg; textFg: windowSubTextFg;
} }
pickLocationButtonSkip: 6px; pickLocationButtonSkip: 6px;
pickLocationSendIcon: icon{{ "chat/filled_location", windowFgActive }}; pickLocationSendIcon: icon{{ "chat/filled_location", windowFgActive }};
pickLocationVenueItem: PeerListItem(defaultPeerListItem) { pickLocationVenueItem: PeerListItem(defaultPeerListItem) {
button: OutlineButton(defaultPeerListButton) { height: pickLocationRowHeight;
font: normalFont; photoSize: 42px;
padding: margins(11px, 5px, 11px, 5px);
}
height: 52px;
photoPosition: point(18px, 5px); photoPosition: point(18px, 5px);
namePosition: point(70px, 7px); namePosition: point(70px, 7px);
statusPosition: point(70px, 27px); 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) { pickLocationVenueList: PeerList(defaultPeerList) {
item: pickLocationVenueItem; item: pickLocationVenueItem;

View file

@ -1822,6 +1822,7 @@ void ChooseAndSendLocation(
Ui::LocationPicker::Show({ Ui::LocationPicker::Show({
.parent = controller->widget(), .parent = controller->widget(),
.config = config, .config = config,
.recipient = action.history->peer,
.session = &controller->session(), .session = &controller->session(),
.callback = crl::guard(controller, callback), .callback = crl::guard(controller, callback),
.quit = [] { Shortcuts::Launch(Shortcuts::Command::Quit); }, .quit = [] { Shortcuts::Launch(Shortcuts::Command::Quit); },

View file

@ -409,7 +409,7 @@ void VenuesController::rowPaintIcon(
st::pickLocationButton); st::pickLocationButton);
const auto raw = result.data(); const auto raw = result.data();
const auto st = &st::pickLocationVenue; const auto st = &st::pickLocationVenueItem;
const auto icon = CreateChild<RpWidget>(raw); const auto icon = CreateChild<RpWidget>(raw);
icon->setGeometry( icon->setGeometry(
st->photoPosition.x(), st->photoPosition.x(),
@ -628,7 +628,8 @@ LocationPicker::LocationPicker(Descriptor &&descriptor)
venuesRequest(*_venuesSearchLocation, *_venuesSearchQuery); venuesRequest(*_venuesSearchLocation, *_venuesSearchQuery);
}) })
, _api(&_session->mtp()) { , _api(&_session->mtp())
, _venueRecipient(descriptor.recipient) {
std::move( std::move(
descriptor.closeRequests descriptor.closeRequests
) | rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
@ -1002,7 +1003,7 @@ void LocationPicker::venuesSendRequest() {
_venuesRequestId = _api.request(MTPmessages_GetInlineBotResults( _venuesRequestId = _api.request(MTPmessages_GetInlineBotResults(
MTP_flags(MTPmessages_GetInlineBotResults::Flag::f_geo_point), MTP_flags(MTPmessages_GetInlineBotResults::Flag::f_geo_point),
_venuesBot->inputUser, _venuesBot->inputUser,
MTP_inputPeerEmpty(), (_venueRecipient ? _venueRecipient->input : MTP_inputPeerEmpty()),
MTP_inputGeoPoint( MTP_inputGeoPoint(
MTP_flags(0), MTP_flags(0),
MTP_double(_venuesRequestLocation.point.x()), MTP_double(_venuesRequestLocation.point.x()),

View file

@ -80,6 +80,7 @@ public:
struct Descriptor { struct Descriptor {
RpWidget *parent = nullptr; RpWidget *parent = nullptr;
LocationPickerConfig config; LocationPickerConfig config;
PeerData *recipient = nullptr;
not_null<Main::Session*> session; not_null<Main::Session*> session;
Fn<void(Data::InputVenue)> callback; Fn<void(Data::InputVenue)> callback;
Fn<void()> quit; Fn<void()> quit;
@ -145,6 +146,7 @@ private:
std::optional<QString> _venuesSearchQuery; std::optional<QString> _venuesSearchQuery;
base::Timer _venuesSearchDebounceTimer; base::Timer _venuesSearchDebounceTimer;
MTP::Sender _api; MTP::Sender _api;
PeerData *_venueRecipient = nullptr;
UserData *_venuesBot = nullptr; UserData *_venuesBot = nullptr;
mtpRequestId _venuesBotRequestId = 0; mtpRequestId _venuesBotRequestId = 0;
mtpRequestId _venuesRequestId = 0; mtpRequestId _venuesRequestId = 0;