Browse Source

Handle keyboardButtonRequestPhone

master
morethanwords 3 years ago
parent
commit
0b1a0ae64e
  1. 27
      src/components/chat/replyKeyboard.ts
  2. 2
      src/components/chat/topbar.ts
  3. 2
      src/lang.ts
  4. 4
      src/lib/appManagers/appMessagesManager.ts

27
src/components/chat/replyKeyboard.ts

@ -7,7 +7,7 @@ @@ -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"; @@ -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 { @@ -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 { @@ -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);
}

2
src/components/chat/topbar.ts

@ -427,7 +427,7 @@ export default class ChatTopbar { @@ -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});
}
}, {

2
src/lang.ts

@ -614,6 +614,8 @@ const lang = { @@ -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",

4
src/lib/appManagers/appMessagesManager.ts

@ -1204,6 +1204,10 @@ export class AppMessagesManager { @@ -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,

Loading…
Cancel
Save