diff --git a/src/components/chat/replyKeyboard.ts b/src/components/chat/replyKeyboard.ts index a8ef1b36..6be1cda0 100644 --- a/src/components/chat/replyKeyboard.ts +++ b/src/components/chat/replyKeyboard.ts @@ -7,7 +7,7 @@ import type { AppMessagesManager } from "../../lib/appManagers/appMessagesManager"; import type ChatInput from "./input"; import DropdownHover from "../../helpers/dropdownHover"; -import { ReplyMarkup } from "../../layer"; +import { KeyboardButton, ReplyMarkup } from "../../layer"; import RichTextProcessor from "../../lib/richtextprocessor"; import rootScope from "../../lib/rootScope"; import { safeAssign } from "../../helpers/object"; @@ -17,6 +17,7 @@ import { IS_TOUCH_SUPPORTED } from "../../environment/touchSupport"; import findUpAsChild from "../../helpers/dom/findUpAsChild"; import { cancelEvent } from "../../helpers/dom/cancelEvent"; import { getHeavyAnimationPromise } from "../../hooks/useHeavyAnimationCheck"; +import confirmationPopup from "../confirmationPopup"; export default class ReplyKeyboard extends DropdownHover { private static BASE_CLASS = 'reply-keyboard'; @@ -78,7 +79,28 @@ export default class ReplyKeyboard extends DropdownHover { return; } - this.appMessagesManager.sendText(this.peerId, target.dataset.text); + const type = target.dataset.type as KeyboardButton['_']; + const {peerId} = this; + switch(type) { + case 'keyboardButtonRequestPhone': { + confirmationPopup({ + titleLangKey: 'ShareYouPhoneNumberTitle', + button: { + langKey: 'OK' + }, + descriptionLangKey: 'AreYouSureShareMyContactInfoBot' + }).then(() => { + this.appMessagesManager.sendContact(peerId, rootScope.myId); + }); + break; + } + + default: { + this.appMessagesManager.sendText(peerId, target.dataset.text); + break; + } + } + this.toggle(false); }); @@ -121,6 +143,7 @@ export default class ReplyKeyboard extends DropdownHover { btn.classList.add(ReplyKeyboard.BASE_CLASS + '-button', 'btn'); btn.innerHTML = RichTextProcessor.wrapEmojiText(button.text); btn.dataset.text = button.text; + btn.dataset.type = button._; div.append(btn); } diff --git a/src/components/chat/topbar.ts b/src/components/chat/topbar.ts index a30135a9..765d0ec9 100644 --- a/src/components/chat/topbar.ts +++ b/src/components/chat/topbar.ts @@ -427,7 +427,7 @@ export default class ChatTopbar { callback: () => { resolve(); - this.appMessagesManager.sendOther(peerId, this.appUsersManager.getContactMediaInput(contactPeerId)); + this.appMessagesManager.sendContact(peerId, contactPeerId); this.chat.appImManager.setInnerPeer({peerId}); } }, { diff --git a/src/lang.ts b/src/lang.ts index 9579da5a..ed57c46e 100644 --- a/src/lang.ts +++ b/src/lang.ts @@ -614,6 +614,8 @@ const lang = { "BotUnblock": "RESTART", "BotStop": "Stop bot", "BotRestart": "Restart bot", + "ShareYouPhoneNumberTitle": "Share your phone number?", + "AreYouSureShareMyContactInfoBot": "The bot will know your phone number. This can be useful for integration with other services.", // * macos "AccountSettings.Filters": "Chat Folders", diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index e20d1a44..edbde1d9 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -1204,6 +1204,10 @@ export class AppMessagesManager { }); } + public sendContact(peerId: PeerId, contactPeerId: PeerId) { + return this.sendOther(peerId, appUsersManager.getContactMediaInput(contactPeerId)); + } + public sendOther(peerId: PeerId, inputMedia: InputMedia, options: Partial<{ replyToMsgId: number, threadId: number,