Added 'Send as...' menu
This commit is contained in:
parent
de278c35c7
commit
a29a42cd44
@ -3069,6 +3069,8 @@ export default class ChatBubbles {
|
|||||||
const isOut = our && (!fwdFrom || this.peerId !== rootScope.myId);
|
const isOut = our && (!fwdFrom || this.peerId !== rootScope.myId);
|
||||||
let nameContainer: HTMLElement = bubbleContainer;
|
let nameContainer: HTMLElement = bubbleContainer;
|
||||||
|
|
||||||
|
const canHideNameIfMedia = !message.viaBotId && message.fromId === rootScope.myId;
|
||||||
|
|
||||||
// media
|
// media
|
||||||
if(messageMedia/* && messageMedia._ === 'messageMediaPhoto' */) {
|
if(messageMedia/* && messageMedia._ === 'messageMediaPhoto' */) {
|
||||||
let attachmentDiv = document.createElement('div');
|
let attachmentDiv = document.createElement('div');
|
||||||
@ -3089,7 +3091,7 @@ export default class ChatBubbles {
|
|||||||
canHaveTail = false;
|
canHaveTail = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!message.viaBotId) {
|
if(canHideNameIfMedia) {
|
||||||
bubble.classList.add('hide-name');
|
bubble.classList.add('hide-name');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3333,7 +3335,7 @@ export default class ChatBubbles {
|
|||||||
canHaveTail = false;
|
canHaveTail = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!message.viaBotId) {
|
if(canHideNameIfMedia) {
|
||||||
bubble.classList.add('hide-name');
|
bubble.classList.add('hide-name');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3540,7 +3542,7 @@ export default class ChatBubbles {
|
|||||||
let savedFrom = '';
|
let savedFrom = '';
|
||||||
|
|
||||||
// const needName = ((peerId.isAnyChat() && (peerId !== message.fromId || our)) && message.fromId !== rootScope.myId) || message.viaBotId;
|
// const needName = ((peerId.isAnyChat() && (peerId !== message.fromId || our)) && message.fromId !== rootScope.myId) || message.viaBotId;
|
||||||
const needName = (message.fromId !== rootScope.myId && this.appPeersManager.isAnyChat(peerId) && !this.appPeersManager.isBroadcast(peerId)) || message.viaBotId || (message as Message.message).pFlags.sponsored;
|
const needName = (message.fromId !== rootScope.myId && this.appPeersManager.isAnyGroup(peerId)) || message.viaBotId || (message as Message.message).pFlags.sponsored;
|
||||||
if(needName || fwdFrom || message.reply_to_mid) { // chat
|
if(needName || fwdFrom || message.reply_to_mid) { // chat
|
||||||
let title: HTMLElement | DocumentFragment;
|
let title: HTMLElement | DocumentFragment;
|
||||||
let titleVia: typeof title;
|
let titleVia: typeof title;
|
||||||
|
@ -220,6 +220,7 @@ export default class ChatInput {
|
|||||||
private sendAsBtnMenu: HTMLElement;
|
private sendAsBtnMenu: HTMLElement;
|
||||||
private sendAsPeerIds: PeerId[];
|
private sendAsPeerIds: PeerId[];
|
||||||
public sendAsPeerId: PeerId;
|
public sendAsPeerId: PeerId;
|
||||||
|
private updatingSendAsPromise: Promise<void>;
|
||||||
|
|
||||||
// private activeContainer: HTMLElement;
|
// private activeContainer: HTMLElement;
|
||||||
|
|
||||||
@ -1232,6 +1233,7 @@ export default class ChatInput {
|
|||||||
sendAsContainer.remove();
|
sendAsContainer.remove();
|
||||||
SetTransition(this.newMessageWrapper, 'has-send-as', false, 0);
|
SetTransition(this.newMessageWrapper, 'has-send-as', false, 0);
|
||||||
this.sendAsPeerId = undefined;
|
this.sendAsPeerId = undefined;
|
||||||
|
this.updatingSendAsPromise = undefined;
|
||||||
|
|
||||||
this.updateSendAs(true);
|
this.updateSendAs(true);
|
||||||
}
|
}
|
||||||
@ -1266,6 +1268,8 @@ export default class ChatInput {
|
|||||||
subtitle.classList.add('btn-menu-item-subtitle');
|
subtitle.classList.add('btn-menu-item-subtitle');
|
||||||
if(sendAsPeerId.isUser()) {
|
if(sendAsPeerId.isUser()) {
|
||||||
subtitle.append(i18n('Chat.SendAs.PersonalAccount'));
|
subtitle.append(i18n('Chat.SendAs.PersonalAccount'));
|
||||||
|
} else if(sendAsPeerId === this.chat.peerId) {
|
||||||
|
subtitle.append(i18n('VoiceChat.DiscussionGroup'));
|
||||||
} else {
|
} else {
|
||||||
subtitle.append(this.appProfileManager.getChatMembersString(sendAsPeerId.toChatId()));
|
subtitle.append(this.appProfileManager.getChatMembersString(sendAsPeerId.toChatId()));
|
||||||
}
|
}
|
||||||
@ -1284,6 +1288,7 @@ export default class ChatInput {
|
|||||||
channelFull.default_send_as = this.appPeersManager.getOutputPeer(sendAsPeerId);
|
channelFull.default_send_as = this.appPeersManager.getOutputPeer(sendAsPeerId);
|
||||||
this.sendAsPeerId = sendAsPeerId;
|
this.sendAsPeerId = sendAsPeerId;
|
||||||
this.updateSendAsAvatar(sendAsPeerId);
|
this.updateSendAsAvatar(sendAsPeerId);
|
||||||
|
this.updateMessageInputPlaceholder();
|
||||||
|
|
||||||
const middleware = this.chat.bubbles.getMiddleware();
|
const middleware = this.chat.bubbles.getMiddleware();
|
||||||
const executeButtonsUpdate = () => {
|
const executeButtonsUpdate = () => {
|
||||||
@ -1368,11 +1373,14 @@ export default class ChatInput {
|
|||||||
|
|
||||||
private updateSendAs(skipAnimation?: boolean) {
|
private updateSendAs(skipAnimation?: boolean) {
|
||||||
const peerId = this.chat.peerId;
|
const peerId = this.chat.peerId;
|
||||||
if(!peerId.isChannel()) {
|
if(!peerId.isChannel() || this.updatingSendAsPromise) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const middleware = this.chat.bubbles.getMiddleware();
|
const middleware = this.chat.bubbles.getMiddleware(() => {
|
||||||
|
return !this.updatingSendAsPromise || this.updatingSendAsPromise === updatingSendAsPromise;
|
||||||
|
});
|
||||||
|
|
||||||
const {sendAsContainer} = this;
|
const {sendAsContainer} = this;
|
||||||
const chatId = peerId.toChatId();
|
const chatId = peerId.toChatId();
|
||||||
const result = this.getDefaultSendAs();
|
const result = this.getDefaultSendAs();
|
||||||
@ -1382,11 +1390,12 @@ export default class ChatInput {
|
|||||||
skipAnimation = undefined;
|
skipAnimation = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
callbackify(result, (sendAsPeerId) => {
|
const updateSendAsResult = callbackify(result, (sendAsPeerId) => {
|
||||||
if(!middleware() || sendAsPeerId === undefined) return;
|
if(!middleware() || sendAsPeerId === undefined) return;
|
||||||
|
|
||||||
this.sendAsPeerId = sendAsPeerId;
|
this.sendAsPeerId = sendAsPeerId;
|
||||||
this.updateSendAsAvatar(sendAsPeerId, skipAnimation);
|
this.updateSendAsAvatar(sendAsPeerId, skipAnimation);
|
||||||
|
this.updateMessageInputPlaceholder();
|
||||||
|
|
||||||
this.appChatsManager.getSendAs(chatId).then(peers => {
|
this.appChatsManager.getSendAs(chatId).then(peers => {
|
||||||
if(!middleware()) return;
|
if(!middleware()) return;
|
||||||
@ -1406,7 +1415,32 @@ export default class ChatInput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetTransition(this.newMessageWrapper, 'has-send-as', true, skipAnimation ? 0 : SEND_AS_ANIMATION_DURATION, undefined, useRafs);
|
SetTransition(this.newMessageWrapper, 'has-send-as', true, skipAnimation ? 0 : SEND_AS_ANIMATION_DURATION, undefined, useRafs);
|
||||||
|
|
||||||
|
this.updatingSendAsPromise = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const updatingSendAsPromise = this.updatingSendAsPromise = Promise.resolve(updateSendAsResult);
|
||||||
|
return updatingSendAsPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateMessageInputPlaceholder() {
|
||||||
|
const i = I18n.weakMap.get(this.messageInput) as I18n.IntlElement;
|
||||||
|
if(i) {
|
||||||
|
const {peerId, threadId} = this.chat;
|
||||||
|
let key: LangPackKey;
|
||||||
|
if(threadId) {
|
||||||
|
key = 'Comment';
|
||||||
|
} else if(this.appPeersManager.isBroadcast(peerId)) {
|
||||||
|
key = 'ChannelBroadcast';
|
||||||
|
} else if((this.sendAsPeerId !== undefined && this.sendAsPeerId !== rootScope.myId) ||
|
||||||
|
this.appMessagesManager.isAnonymousSending(peerId)) {
|
||||||
|
key = 'SendAnonymously';
|
||||||
|
} else {
|
||||||
|
key = 'Message';
|
||||||
|
}
|
||||||
|
|
||||||
|
i.compareAndUpdate({key});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateMessageInput() {
|
public updateMessageInput() {
|
||||||
@ -1422,21 +1456,7 @@ export default class ChatInput {
|
|||||||
chatInput.classList.remove('no-transition');
|
chatInput.classList.remove('no-transition');
|
||||||
}
|
}
|
||||||
|
|
||||||
const i = I18n.weakMap.get(messageInput) as I18n.IntlElement;
|
this.updateMessageInputPlaceholder();
|
||||||
if(i) {
|
|
||||||
let key: LangPackKey;
|
|
||||||
if(threadId) {
|
|
||||||
key = 'Comment';
|
|
||||||
} else if(this.appPeersManager.isBroadcast(peerId)) {
|
|
||||||
key = 'ChannelBroadcast';
|
|
||||||
} else if(this.appMessagesManager.isAnonymousSending(peerId)) {
|
|
||||||
key = 'SendAnonymously';
|
|
||||||
} else {
|
|
||||||
key = 'Message';
|
|
||||||
}
|
|
||||||
|
|
||||||
i.compareAndUpdate({key});
|
|
||||||
}
|
|
||||||
|
|
||||||
const visible = this.attachMenuButtons.filter(button => {
|
const visible = this.attachMenuButtons.filter(button => {
|
||||||
const good = button.verify(peerId, threadId);
|
const good = button.verify(peerId, threadId);
|
||||||
|
@ -232,9 +232,9 @@ export default class PeerProfile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public setPeerStatus = (needClear = false) => {
|
public setPeerStatus = (needClear = false) => {
|
||||||
if(!this.peerId) return;
|
|
||||||
|
|
||||||
const peerId = this.peerId;
|
const peerId = this.peerId;
|
||||||
|
if(!peerId || rootScope.myId === peerId) return;
|
||||||
|
|
||||||
appImManager.setPeerStatus(this.peerId, this.subtitle, needClear, true, () => peerId === this.peerId, !this.isDialog);
|
appImManager.setPeerStatus(this.peerId, this.subtitle, needClear, true, () => peerId === this.peerId, !this.isDialog);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ import { AccountAuthorizations, Authorization } from "/Users/kuzmenko/Documents/
|
|||||||
import { SliderSuperTabConstructable } from "../../sliderTab";
|
import { SliderSuperTabConstructable } from "../../sliderTab";
|
||||||
import PopupAvatar from "../../popups/avatar";
|
import PopupAvatar from "../../popups/avatar";
|
||||||
import appProfileManager from "../../../lib/appManagers/appProfileManager";
|
import appProfileManager from "../../../lib/appManagers/appProfileManager";
|
||||||
|
import appUsersManager from "../../../lib/appManagers/appUsersManager";
|
||||||
//import AppMediaViewer from "../../appMediaViewerNew";
|
//import AppMediaViewer from "../../appMediaViewerNew";
|
||||||
|
|
||||||
export default class AppSettingsTab extends SliderSuperTab {
|
export default class AppSettingsTab extends SliderSuperTab {
|
||||||
@ -78,16 +79,19 @@ export default class AppSettingsTab extends SliderSuperTab {
|
|||||||
this.profile.setPeer(rootScope.myId);
|
this.profile.setPeer(rootScope.myId);
|
||||||
this.profile.fillProfileElements();
|
this.profile.fillProfileElements();
|
||||||
|
|
||||||
const changeAvatarBtn = Button('btn-circle btn-corner z-depth-1 profile-change-avatar', {icon: 'cameraadd'});
|
const user = appUsersManager.getSelf();
|
||||||
changeAvatarBtn.addEventListener('click', () => {
|
if(user.photo?._ === 'userProfilePhoto') {
|
||||||
const canvas = document.createElement('canvas');
|
const changeAvatarBtn = Button('btn-circle btn-corner z-depth-1 profile-change-avatar', {icon: 'cameraadd'});
|
||||||
new PopupAvatar().open(canvas, (upload) => {
|
changeAvatarBtn.addEventListener('click', () => {
|
||||||
upload().then(inputFile => {
|
const canvas = document.createElement('canvas');
|
||||||
return appProfileManager.uploadProfilePhoto(inputFile);
|
new PopupAvatar().open(canvas, (upload) => {
|
||||||
|
upload().then(inputFile => {
|
||||||
|
return appProfileManager.uploadProfilePhoto(inputFile);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
this.profile.element.lastElementChild.firstElementChild.append(changeAvatarBtn);
|
||||||
this.profile.element.lastElementChild.firstElementChild.append(changeAvatarBtn);
|
}
|
||||||
|
|
||||||
/* const div = document.createElement('div');
|
/* const div = document.createElement('div');
|
||||||
//div.style.cssText = 'border-radius: 8px; overflow: hidden; width: 396px; height: 264px; flex: 0 0 auto; position: relative; margin: 10rem 0 10rem auto;';
|
//div.style.cssText = 'border-radius: 8px; overflow: hidden; width: 396px; height: 264px; flex: 0 0 auto; position: relative; margin: 10rem 0 10rem auto;';
|
||||||
|
@ -19,7 +19,7 @@ const App = {
|
|||||||
version: process.env.VERSION,
|
version: process.env.VERSION,
|
||||||
versionFull: process.env.VERSION_FULL,
|
versionFull: process.env.VERSION_FULL,
|
||||||
build: +process.env.BUILD,
|
build: +process.env.BUILD,
|
||||||
langPackVersion: '0.3.9',
|
langPackVersion: '0.4.0',
|
||||||
langPack: 'macos',
|
langPack: 'macos',
|
||||||
langPackCode: 'en',
|
langPackCode: 'en',
|
||||||
domains: [MAIN_DOMAIN] as string[],
|
domains: [MAIN_DOMAIN] as string[],
|
||||||
|
@ -133,6 +133,8 @@ const lang = {
|
|||||||
"PushNotification.Message.NoPreview": "You have a new message",
|
"PushNotification.Message.NoPreview": "You have a new message",
|
||||||
"LogOut.Description": "Are you sure you want to log out?\n\nNote that you can seamlessly use Telegram on all your devices at once.",
|
"LogOut.Description": "Are you sure you want to log out?\n\nNote that you can seamlessly use Telegram on all your devices at once.",
|
||||||
//"PushNotification.Action.Mute1d.Success": "Notification settings were successfully saved.",
|
//"PushNotification.Action.Mute1d.Success": "Notification settings were successfully saved.",
|
||||||
|
//it is from iOS
|
||||||
|
"VoiceChat.DiscussionGroup": "discussion group",
|
||||||
|
|
||||||
// * android
|
// * android
|
||||||
"AccDescrEditing": "Editing",
|
"AccDescrEditing": "Editing",
|
||||||
|
Loading…
Reference in New Issue
Block a user