Share contact
This commit is contained in:
parent
bd3eed26fb
commit
1afeacf368
@ -173,7 +173,7 @@ export default class Chat extends EventListenerBase<{
|
|||||||
public init(/* peerId: number */) {
|
public init(/* peerId: number */) {
|
||||||
// this.initPeerId = peerId;
|
// this.initPeerId = peerId;
|
||||||
|
|
||||||
this.topbar = new ChatTopbar(this, appSidebarRight, this.appMessagesManager, this.appPeersManager, this.appChatsManager, this.appNotificationsManager, this.appProfileManager);
|
this.topbar = new ChatTopbar(this, appSidebarRight, this.appMessagesManager, this.appPeersManager, this.appChatsManager, this.appNotificationsManager, this.appProfileManager, this.appUsersManager);
|
||||||
this.bubbles = new ChatBubbles(this, this.appMessagesManager, this.appStickersManager, this.appUsersManager, this.appInlineBotsManager, this.appPhotosManager, this.appPeersManager, this.appProfileManager, this.appDraftsManager, this.appMessagesIdsManager);
|
this.bubbles = new ChatBubbles(this, this.appMessagesManager, this.appStickersManager, this.appUsersManager, this.appInlineBotsManager, this.appPhotosManager, this.appPeersManager, this.appProfileManager, this.appDraftsManager, this.appMessagesIdsManager);
|
||||||
this.input = new ChatInput(this, this.appMessagesManager, this.appMessagesIdsManager, this.appDocsManager, this.appChatsManager, this.appPeersManager, this.appWebPagesManager, this.appImManager, this.appDraftsManager, this.serverTimeManager, this.appNotificationsManager, this.appEmojiManager, this.appUsersManager, this.appInlineBotsManager);
|
this.input = new ChatInput(this, this.appMessagesManager, this.appMessagesIdsManager, this.appDocsManager, this.appChatsManager, this.appPeersManager, this.appWebPagesManager, this.appImManager, this.appDraftsManager, this.serverTimeManager, this.appNotificationsManager, this.appEmojiManager, this.appUsersManager, this.appInlineBotsManager);
|
||||||
this.selection = new ChatSelection(this, this.bubbles, this.input, this.appMessagesManager);
|
this.selection = new ChatSelection(this, this.bubbles, this.input, this.appMessagesManager);
|
||||||
|
@ -10,6 +10,7 @@ import type { AppMessagesManager } from "../../lib/appManagers/appMessagesManage
|
|||||||
import type { AppPeersManager } from "../../lib/appManagers/appPeersManager";
|
import type { AppPeersManager } from "../../lib/appManagers/appPeersManager";
|
||||||
import type { AppSidebarRight } from "../sidebarRight";
|
import type { AppSidebarRight } from "../sidebarRight";
|
||||||
import type { AppProfileManager } from "../../lib/appManagers/appProfileManager";
|
import type { AppProfileManager } from "../../lib/appManagers/appProfileManager";
|
||||||
|
import type { AppUsersManager } from "../../lib/appManagers/appUsersManager";
|
||||||
import type Chat from "./chat";
|
import type Chat from "./chat";
|
||||||
import { RIGHT_COLUMN_ACTIVE_CLASSNAME } from "../sidebarRight";
|
import { RIGHT_COLUMN_ACTIVE_CLASSNAME } from "../sidebarRight";
|
||||||
import mediaSizes, { ScreenSize } from "../../helpers/mediaSizes";
|
import mediaSizes, { ScreenSize } from "../../helpers/mediaSizes";
|
||||||
@ -37,6 +38,8 @@ import findUpTag from "../../helpers/dom/findUpTag";
|
|||||||
import { toast } from "../toast";
|
import { toast } from "../toast";
|
||||||
import replaceContent from "../../helpers/dom/replaceContent";
|
import replaceContent from "../../helpers/dom/replaceContent";
|
||||||
import { ChatFull } from "../../layer";
|
import { ChatFull } from "../../layer";
|
||||||
|
import PopupPickUser from "../popups/pickUser";
|
||||||
|
import PopupPeer from "../popups/peer";
|
||||||
|
|
||||||
export default class ChatTopbar {
|
export default class ChatTopbar {
|
||||||
public container: HTMLDivElement;
|
public container: HTMLDivElement;
|
||||||
@ -70,7 +73,8 @@ export default class ChatTopbar {
|
|||||||
private appPeersManager: AppPeersManager,
|
private appPeersManager: AppPeersManager,
|
||||||
private appChatsManager: AppChatsManager,
|
private appChatsManager: AppChatsManager,
|
||||||
private appNotificationsManager: AppNotificationsManager,
|
private appNotificationsManager: AppNotificationsManager,
|
||||||
private appProfileManager: AppProfileManager
|
private appProfileManager: AppProfileManager,
|
||||||
|
private appUsersManager: AppUsersManager
|
||||||
) {
|
) {
|
||||||
this.listenerSetter = new ListenerSetter();
|
this.listenerSetter = new ListenerSetter();
|
||||||
}
|
}
|
||||||
@ -211,6 +215,45 @@ export default class ChatTopbar {
|
|||||||
onClick: () => this.openPinned(false),
|
onClick: () => this.openPinned(false),
|
||||||
verify: () => mediaSizes.isMobile
|
verify: () => mediaSizes.isMobile
|
||||||
}, */ {
|
}, */ {
|
||||||
|
icon: 'forward',
|
||||||
|
text: 'ShareContact',
|
||||||
|
onClick: () => {
|
||||||
|
const contactPeerId = this.peerId;
|
||||||
|
new PopupPickUser({
|
||||||
|
peerTypes: ['dialogs', 'contacts'],
|
||||||
|
onSelect: (peerId) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
new PopupPeer('', {
|
||||||
|
titleLangKey: 'SendMessageTitle',
|
||||||
|
descriptionLangKey: 'SendContactToGroupText',
|
||||||
|
descriptionLangArgs: [new PeerTitle({peerId, dialog: true}).element],
|
||||||
|
buttons: [{
|
||||||
|
langKey: 'Send',
|
||||||
|
callback: () => {
|
||||||
|
resolve();
|
||||||
|
|
||||||
|
this.appMessagesManager.sendOther(peerId, this.appUsersManager.getContactMediaInput(contactPeerId));
|
||||||
|
this.chat.appImManager.setInnerPeer(peerId);
|
||||||
|
}
|
||||||
|
}, {
|
||||||
|
langKey: 'Cancel',
|
||||||
|
callback: () => {
|
||||||
|
reject();
|
||||||
|
},
|
||||||
|
isCancel: true,
|
||||||
|
}],
|
||||||
|
peerId,
|
||||||
|
overlayClosable: true
|
||||||
|
}).show();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
placeholder: 'ShareModal.Search.Placeholder',
|
||||||
|
chatRightsAction: 'send_messages',
|
||||||
|
selfPresence: 'ChatYourSelf'
|
||||||
|
});
|
||||||
|
},
|
||||||
|
verify: () => rootScope.myId !== this.peerId && this.peerId > 0 && this.appUsersManager.isContact(this.peerId)
|
||||||
|
}, {
|
||||||
icon: 'mute',
|
icon: 'mute',
|
||||||
text: 'ChatList.Context.Mute',
|
text: 'ChatList.Context.Mute',
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
|
@ -102,10 +102,6 @@ class InputField {
|
|||||||
this.required = options.required;
|
this.required = options.required;
|
||||||
this.validate = options.validate;
|
this.validate = options.validate;
|
||||||
|
|
||||||
if(this.required) {
|
|
||||||
this.originalValue = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if(options.maxLength) {
|
if(options.maxLength) {
|
||||||
options.showLengthOn = Math.min(40, Math.round(options.maxLength / 3));
|
options.showLengthOn = Math.min(40, Math.round(options.maxLength / 3));
|
||||||
}
|
}
|
||||||
@ -276,7 +272,10 @@ class InputField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public isValid() {
|
public isValid() {
|
||||||
return !this.input.classList.contains('error') && this.isChanged() && (!this.validate || this.validate());
|
return !this.input.classList.contains('error') &&
|
||||||
|
this.isChanged() &&
|
||||||
|
(!this.validate || this.validate()) &&
|
||||||
|
(!this.required || !isInputEmpty(this.input));
|
||||||
}
|
}
|
||||||
|
|
||||||
public setOriginalValue(value: InputField['originalValue'] = '', silent = false) {
|
public setOriginalValue(value: InputField['originalValue'] = '', silent = false) {
|
||||||
|
@ -28,17 +28,21 @@ export default class PopupPickUser extends PopupElement {
|
|||||||
this.selector = new AppSelectPeers({
|
this.selector = new AppSelectPeers({
|
||||||
appendTo: this.body,
|
appendTo: this.body,
|
||||||
onChange: async() => {
|
onChange: async() => {
|
||||||
const peerId = this.selector.getSelected()[0];
|
const selected = this.selector.getSelected();
|
||||||
|
const peerId = selected[selected.length - 1];
|
||||||
this.selector = null;
|
|
||||||
|
|
||||||
if(options.onSelect) {
|
if(options.onSelect) {
|
||||||
const res = options.onSelect(peerId);
|
const res = options.onSelect(peerId);
|
||||||
if(res instanceof Promise) {
|
if(res instanceof Promise) {
|
||||||
await res;
|
try {
|
||||||
|
await res;
|
||||||
|
} catch(err) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.selector = null;
|
||||||
this.hide();
|
this.hide();
|
||||||
},
|
},
|
||||||
peerType: options.peerTypes,
|
peerType: options.peerTypes,
|
||||||
|
@ -562,6 +562,9 @@ const lang = {
|
|||||||
"ReportSentInfo": "Telegram moderators will review your report.\nThank you for your cooperation!",
|
"ReportSentInfo": "Telegram moderators will review your report.\nThank you for your cooperation!",
|
||||||
"ReportHint": "Additional details...",
|
"ReportHint": "Additional details...",
|
||||||
"ChatHistory": "Chat history for new members",
|
"ChatHistory": "Chat history for new members",
|
||||||
|
"ShareContact": "Share contact",
|
||||||
|
"SendMessageTitle": "Send message",
|
||||||
|
"SendContactToGroupText": "Do you want to send this contact to **%1$s**?",
|
||||||
|
|
||||||
// * macos
|
// * macos
|
||||||
"AccountSettings.Filters": "Chat Folders",
|
"AccountSettings.Filters": "Chat Folders",
|
||||||
@ -694,6 +697,7 @@ const lang = {
|
|||||||
"Stickers.SearchAdd": "Add",
|
"Stickers.SearchAdd": "Add",
|
||||||
"Stickers.SearchAdded": "Added",
|
"Stickers.SearchAdded": "Added",
|
||||||
"Stickers.SuggestStickers": "Suggest Stickers by Emoji",
|
"Stickers.SuggestStickers": "Suggest Stickers by Emoji",
|
||||||
|
"ShareModal.Search.Placeholder": "Share to...",
|
||||||
"ShareModal.Search.ForwardPlaceholder": "Forward to...",
|
"ShareModal.Search.ForwardPlaceholder": "Forward to...",
|
||||||
"InstalledStickers.LoopAnimated": "Loop Animated Stickers",
|
"InstalledStickers.LoopAnimated": "Loop Animated Stickers",
|
||||||
"Peer.Activity.User.PlayingGame": "playing a game",
|
"Peer.Activity.User.PlayingGame": "playing a game",
|
||||||
|
3
src/layer.d.ts
vendored
3
src/layer.d.ts
vendored
@ -157,7 +157,8 @@ export namespace InputMedia {
|
|||||||
phone_number: string,
|
phone_number: string,
|
||||||
first_name: string,
|
first_name: string,
|
||||||
last_name: string,
|
last_name: string,
|
||||||
vcard: string
|
vcard: string,
|
||||||
|
user_id?: number
|
||||||
};
|
};
|
||||||
|
|
||||||
export type inputMediaUploadedDocument = {
|
export type inputMediaUploadedDocument = {
|
||||||
|
@ -1224,7 +1224,7 @@ export class AppMessagesManager {
|
|||||||
phone_number: inputMedia.phone_number,
|
phone_number: inputMedia.phone_number,
|
||||||
first_name: inputMedia.first_name,
|
first_name: inputMedia.first_name,
|
||||||
last_name: inputMedia.last_name,
|
last_name: inputMedia.last_name,
|
||||||
user_id: 0,
|
user_id: inputMedia.user_id ?? 0,
|
||||||
vcard: inputMedia.vcard
|
vcard: inputMedia.vcard
|
||||||
};
|
};
|
||||||
break;
|
break;
|
||||||
|
@ -17,7 +17,7 @@ import cleanUsername from "../../helpers/cleanUsername";
|
|||||||
import { tsNow } from "../../helpers/date";
|
import { tsNow } from "../../helpers/date";
|
||||||
import { formatPhoneNumber } from "../../helpers/formatPhoneNumber";
|
import { formatPhoneNumber } from "../../helpers/formatPhoneNumber";
|
||||||
import { safeReplaceObject, isObject } from "../../helpers/object";
|
import { safeReplaceObject, isObject } from "../../helpers/object";
|
||||||
import { Chat, InputContact, InputUser, User as MTUser, UserProfilePhoto, UserStatus } from "../../layer";
|
import { Chat, InputContact, InputMedia, InputUser, User as MTUser, UserProfilePhoto, UserStatus } from "../../layer";
|
||||||
import I18n, { i18n, LangPackKey } from "../langPack";
|
import I18n, { i18n, LangPackKey } from "../langPack";
|
||||||
//import apiManager from '../mtproto/apiManager';
|
//import apiManager from '../mtproto/apiManager';
|
||||||
import apiManager from '../mtproto/mtprotoworker';
|
import apiManager from '../mtproto/mtprotoworker';
|
||||||
@ -651,6 +651,19 @@ export class AppUsersManager {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getContactMediaInput(id: number): InputMedia.inputMediaContact {
|
||||||
|
const user = this.getUser(id);
|
||||||
|
|
||||||
|
return {
|
||||||
|
_: 'inputMediaContact',
|
||||||
|
first_name: user.first_name,
|
||||||
|
last_name: user.last_name,
|
||||||
|
phone_number: user.phone,
|
||||||
|
vcard: '',
|
||||||
|
user_id: id
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public updateUsersStatuses = () => {
|
public updateUsersStatuses = () => {
|
||||||
const timestampNow = tsNow(true);
|
const timestampNow = tsNow(true);
|
||||||
for(const i in this.users) {
|
for(const i in this.users) {
|
||||||
|
@ -311,4 +311,9 @@
|
|||||||
{"name": "rTitle", "type": "string"},
|
{"name": "rTitle", "type": "string"},
|
||||||
{"name": "rDescription", "type": "string"}
|
{"name": "rDescription", "type": "string"}
|
||||||
]
|
]
|
||||||
|
}, {
|
||||||
|
"predicate": "inputMediaContact",
|
||||||
|
"params": [
|
||||||
|
{"name": "user_id", "type": "number"}
|
||||||
|
]
|
||||||
}]
|
}]
|
Loading…
Reference in New Issue
Block a user