Add choose chat for bot confirmation.
This commit is contained in:
		
							parent
							
								
									bbd8571c9a
								
							
						
					
					
						commit
						17ce93fd5e
					
				
					 3 changed files with 33 additions and 7 deletions
				
			
		| 
						 | 
					@ -1483,6 +1483,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
"lng_action_topic_renamed" = "{from} renamed the {link} to «{title}»";
 | 
					"lng_action_topic_renamed" = "{from} renamed the {link} to «{title}»";
 | 
				
			||||||
"lng_action_topic_icon_changed" = "{from} changed the {link} icon to {emoji}";
 | 
					"lng_action_topic_icon_changed" = "{from} changed the {link} icon to {emoji}";
 | 
				
			||||||
"lng_action_topic_icon_removed" = "{from} removed the {link} icon";
 | 
					"lng_action_topic_icon_removed" = "{from} removed the {link} icon";
 | 
				
			||||||
 | 
					"lng_action_shared_chat_with_bot" = "You shared {chat} with {bot}";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
"lng_premium_gift_duration_months#one" = "for {count} month";
 | 
					"lng_premium_gift_duration_months#one" = "for {count} month";
 | 
				
			||||||
"lng_premium_gift_duration_months#other" = "for {count} months";
 | 
					"lng_premium_gift_duration_months#other" = "for {count} months";
 | 
				
			||||||
| 
						 | 
					@ -3554,6 +3555,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
"lng_request_peer_requirements" = "Requirements";
 | 
					"lng_request_peer_requirements" = "Requirements";
 | 
				
			||||||
"lng_request_peer_rights" = "You should have the admin rights to {rights}.";
 | 
					"lng_request_peer_rights" = "You should have the admin rights to {rights}.";
 | 
				
			||||||
"lng_request_peer_rights_and" = "{rights} and {last}";
 | 
					"lng_request_peer_rights_and" = "{rights} and {last}";
 | 
				
			||||||
 | 
					"lng_request_peer_confirm" = "Are you sure you want to send {chat} to {bot}?";
 | 
				
			||||||
 | 
					"lng_request_peer_confirm_add" = "This will also add {bot} to {chat}.";
 | 
				
			||||||
 | 
					"lng_request_peer_confirm_rights" = "This will also add {bot} to {chat} with the following rights: {rights}.";
 | 
				
			||||||
 | 
					"lng_request_peer_confirm_send" = "Send";
 | 
				
			||||||
"lng_request_user_title" = "Choose User";
 | 
					"lng_request_user_title" = "Choose User";
 | 
				
			||||||
"lng_request_user_premium_yes" = "The user should have a Premium subscription.";
 | 
					"lng_request_user_premium_yes" = "The user should have a Premium subscription.";
 | 
				
			||||||
"lng_request_user_premium_no" = "The user shouldn't have a Premium subscription.";
 | 
					"lng_request_user_premium_no" = "The user shouldn't have a Premium subscription.";
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -19,6 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
 | 
				
			||||||
#include "info/profile/info_profile_icon.h"
 | 
					#include "info/profile/info_profile_icon.h"
 | 
				
			||||||
#include "lang/lang_keys.h"
 | 
					#include "lang/lang_keys.h"
 | 
				
			||||||
#include "settings/settings_common.h"
 | 
					#include "settings/settings_common.h"
 | 
				
			||||||
 | 
					#include "ui/boxes/confirm_box.h"
 | 
				
			||||||
#include "ui/widgets/buttons.h"
 | 
					#include "ui/widgets/buttons.h"
 | 
				
			||||||
#include "ui/wrap/vertical_layout.h"
 | 
					#include "ui/wrap/vertical_layout.h"
 | 
				
			||||||
#include "window/window_session_controller.h"
 | 
					#include "window/window_session_controller.h"
 | 
				
			||||||
| 
						 | 
					@ -169,6 +170,19 @@ private:
 | 
				
			||||||
	return result;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					object_ptr<Ui::BoxContent> MakeConfirmBox(
 | 
				
			||||||
 | 
							not_null<UserData*> bot,
 | 
				
			||||||
 | 
							not_null<PeerData*> peer,
 | 
				
			||||||
 | 
							RequestPeerQuery query,
 | 
				
			||||||
 | 
							Fn<void()> confirmed) {
 | 
				
			||||||
 | 
						auto text = TextWithEntities{ "Sure?.." };
 | 
				
			||||||
 | 
						return Ui::MakeConfirmBox({
 | 
				
			||||||
 | 
							.text = std::move(text),
 | 
				
			||||||
 | 
							.confirmed = std::move(confirmed),
 | 
				
			||||||
 | 
							.confirmText = tr::lng_request_peer_confirm_send(tr::now),
 | 
				
			||||||
 | 
						});
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
object_ptr<Ui::BoxContent> CreatePeerByQueryBox(
 | 
					object_ptr<Ui::BoxContent> CreatePeerByQueryBox(
 | 
				
			||||||
		not_null<Window::SessionNavigation*> navigation,
 | 
							not_null<Window::SessionNavigation*> navigation,
 | 
				
			||||||
		not_null<UserData*> bot,
 | 
							not_null<UserData*> bot,
 | 
				
			||||||
| 
						 | 
					@ -334,8 +348,12 @@ void ChoosePeerBoxController::prepareViewHook() {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ChoosePeerBoxController::rowClicked(not_null<PeerListRow*> row) {
 | 
					void ChoosePeerBoxController::rowClicked(not_null<PeerListRow*> row) {
 | 
				
			||||||
	const auto onstack = _callback;
 | 
						const auto peer = row->peer();
 | 
				
			||||||
	onstack(row->peer());
 | 
						const auto done = [callback = _callback, peer] {
 | 
				
			||||||
 | 
							const auto onstack = callback;
 | 
				
			||||||
 | 
							onstack(peer);
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
						delegate()->peerListShowBox(MakeConfirmBox(_bot, peer, _query, done));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
auto ChoosePeerBoxController::createRow(not_null<History*> history)
 | 
					auto ChoosePeerBoxController::createRow(not_null<History*> history)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -4130,12 +4130,15 @@ void HistoryItem::setServiceMessageByAction(const MTPmessageAction &action) {
 | 
				
			||||||
		const auto peerId = peerFromMTP(action.vpeer());
 | 
							const auto peerId = peerFromMTP(action.vpeer());
 | 
				
			||||||
		const auto peer = history()->owner().peer(peerId);
 | 
							const auto peer = history()->owner().peer(peerId);
 | 
				
			||||||
		auto result = PreparedServiceText{};
 | 
							auto result = PreparedServiceText{};
 | 
				
			||||||
		result.text = TextWithEntities{
 | 
							result.text = tr::lng_action_shared_chat_with_bot(
 | 
				
			||||||
			u"You chose "_q
 | 
								tr::now,
 | 
				
			||||||
		}.append(
 | 
								lt_chat,
 | 
				
			||||||
			Ui::Text::Link(peer->name(), 1)
 | 
								Ui::Text::Link(peer->name(), 1),
 | 
				
			||||||
		).append(u" for the bot."_q);
 | 
								lt_bot,
 | 
				
			||||||
 | 
								Ui::Text::Link(history()->peer->name(), 2),
 | 
				
			||||||
 | 
								Ui::Text::WithEntities);
 | 
				
			||||||
		result.links.push_back(peer->createOpenLink());
 | 
							result.links.push_back(peer->createOpenLink());
 | 
				
			||||||
 | 
							result.links.push_back(history()->peer->createOpenLink());
 | 
				
			||||||
		return result;
 | 
							return result;
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue