Handle keyboardButtonRequestPhone
This commit is contained in:
parent
466a9c5bc1
commit
0b1a0ae64e
@ -7,7 +7,7 @@
|
|||||||
import type { AppMessagesManager } from "../../lib/appManagers/appMessagesManager";
|
import type { AppMessagesManager } from "../../lib/appManagers/appMessagesManager";
|
||||||
import type ChatInput from "./input";
|
import type ChatInput from "./input";
|
||||||
import DropdownHover from "../../helpers/dropdownHover";
|
import DropdownHover from "../../helpers/dropdownHover";
|
||||||
import { ReplyMarkup } from "../../layer";
|
import { KeyboardButton, ReplyMarkup } from "../../layer";
|
||||||
import RichTextProcessor from "../../lib/richtextprocessor";
|
import RichTextProcessor from "../../lib/richtextprocessor";
|
||||||
import rootScope from "../../lib/rootScope";
|
import rootScope from "../../lib/rootScope";
|
||||||
import { safeAssign } from "../../helpers/object";
|
import { safeAssign } from "../../helpers/object";
|
||||||
@ -17,6 +17,7 @@ import { IS_TOUCH_SUPPORTED } from "../../environment/touchSupport";
|
|||||||
import findUpAsChild from "../../helpers/dom/findUpAsChild";
|
import findUpAsChild from "../../helpers/dom/findUpAsChild";
|
||||||
import { cancelEvent } from "../../helpers/dom/cancelEvent";
|
import { cancelEvent } from "../../helpers/dom/cancelEvent";
|
||||||
import { getHeavyAnimationPromise } from "../../hooks/useHeavyAnimationCheck";
|
import { getHeavyAnimationPromise } from "../../hooks/useHeavyAnimationCheck";
|
||||||
|
import confirmationPopup from "../confirmationPopup";
|
||||||
|
|
||||||
export default class ReplyKeyboard extends DropdownHover {
|
export default class ReplyKeyboard extends DropdownHover {
|
||||||
private static BASE_CLASS = 'reply-keyboard';
|
private static BASE_CLASS = 'reply-keyboard';
|
||||||
@ -78,7 +79,28 @@ export default class ReplyKeyboard extends DropdownHover {
|
|||||||
return;
|
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);
|
this.toggle(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -121,6 +143,7 @@ export default class ReplyKeyboard extends DropdownHover {
|
|||||||
btn.classList.add(ReplyKeyboard.BASE_CLASS + '-button', 'btn');
|
btn.classList.add(ReplyKeyboard.BASE_CLASS + '-button', 'btn');
|
||||||
btn.innerHTML = RichTextProcessor.wrapEmojiText(button.text);
|
btn.innerHTML = RichTextProcessor.wrapEmojiText(button.text);
|
||||||
btn.dataset.text = button.text;
|
btn.dataset.text = button.text;
|
||||||
|
btn.dataset.type = button._;
|
||||||
div.append(btn);
|
div.append(btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,7 +427,7 @@ export default class ChatTopbar {
|
|||||||
callback: () => {
|
callback: () => {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
||||||
this.appMessagesManager.sendOther(peerId, this.appUsersManager.getContactMediaInput(contactPeerId));
|
this.appMessagesManager.sendContact(peerId, contactPeerId);
|
||||||
this.chat.appImManager.setInnerPeer({peerId});
|
this.chat.appImManager.setInnerPeer({peerId});
|
||||||
}
|
}
|
||||||
}, {
|
}, {
|
||||||
|
@ -614,6 +614,8 @@ const lang = {
|
|||||||
"BotUnblock": "RESTART",
|
"BotUnblock": "RESTART",
|
||||||
"BotStop": "Stop bot",
|
"BotStop": "Stop bot",
|
||||||
"BotRestart": "Restart 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
|
// * macos
|
||||||
"AccountSettings.Filters": "Chat Folders",
|
"AccountSettings.Filters": "Chat Folders",
|
||||||
|
@ -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<{
|
public sendOther(peerId: PeerId, inputMedia: InputMedia, options: Partial<{
|
||||||
replyToMsgId: number,
|
replyToMsgId: number,
|
||||||
threadId: number,
|
threadId: number,
|
||||||
|
Loading…
Reference in New Issue
Block a user