diff --git a/src/components/chat/input.ts b/src/components/chat/input.ts index 6de0c077..65b47a63 100644 --- a/src/components/chat/input.ts +++ b/src/components/chat/input.ts @@ -45,7 +45,7 @@ import PopupPinMessage from '../popups/unpinMessage'; import { tsNow } from '../../helpers/date'; import appNavigationController from '../appNavigationController'; import { isMobile, isMobileSafari } from '../../helpers/userAgent'; -import { i18n, join } from '../../lib/langPack'; +import I18n, { i18n, join, LangPackKey } from '../../lib/langPack'; import { generateTail } from './bubbles'; import findUpClassName from '../../helpers/dom/findUpClassName'; import ButtonCorner from '../buttonCorner'; @@ -816,14 +816,34 @@ export default class ChatInput { } public updateMessageInput() { - const canWrite = this.appMessagesManager.canSendToPeer(this.chat.peerId, this.chat.threadId); + const {peerId, threadId} = this.chat; + const canWrite = this.appMessagesManager.canSendToPeer(peerId, threadId); this.chatInput.classList.add('no-transition'); this.chatInput.classList.toggle('is-hidden', !canWrite); void this.chatInput.offsetLeft; // reflow this.chatInput.classList.remove('no-transition'); + const i = I18n.weakMap.get(this.messageInput) as I18n.IntlElement; + 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'; + } + + if(i.key !== key) { + i.key = key; + i.update(); + } + } + const visible = this.attachMenuButtons.filter(button => { - const good = button.verify(this.chat.peerId, this.chat.threadId); + const good = button.verify(peerId, threadId); button.element.classList.toggle('hide', !good); return good; }); diff --git a/src/lang.ts b/src/lang.ts index fd164b07..a011a8d6 100644 --- a/src/lang.ts +++ b/src/lang.ts @@ -568,6 +568,10 @@ const lang = { "ShareContact": "Share contact", "SendMessageTitle": "Send message", "SendContactToGroupText": "Do you want to send this contact to **%1$s**?", + "ChannelBroadcast": "Broadcast", + "ChannelSilentBroadcast": "Silent Broadcast", + "Comment": "Comment", + "SendAnonymously": "Send anonymously", // * macos "AccountSettings.Filters": "Chat Folders", diff --git a/src/lib/appManagers/appMessagesManager.ts b/src/lib/appManagers/appMessagesManager.ts index 99b64219..a06bd064 100644 --- a/src/lib/appManagers/appMessagesManager.ts +++ b/src/lib/appManagers/appMessagesManager.ts @@ -1509,7 +1509,7 @@ export class AppMessagesManager { * Generate correct from_id according to anonymous or broadcast */ private generateFromId(peerId: number) { - if(peerId < 0 && (appPeersManager.isBroadcast(peerId) || appPeersManager.getPeer(peerId).admin_rights?.pFlags?.anonymous)) { + if(peerId < 0 && (appPeersManager.isBroadcast(peerId) || this.isAnonymousSending(peerId))) { return undefined; } else { return appPeersManager.getOutputPeer(appUsersManager.getSelf().id); @@ -1590,6 +1590,10 @@ export class AppMessagesManager { return message; } + public isAnonymousSending(peerId: number): boolean { + return peerId < 0 && appPeersManager.getPeer(peerId).admin_rights?.pFlags?.anonymous; + } + public setDialogTopMessage(message: MyMessage, dialog: MTDialog.dialog = this.getDialogOnly(message.peerId)) { if(dialog) { dialog.top_message = message.mid;