Browse Source

Change input placeholder by peer type

master
morethanwords 3 years ago
parent
commit
af1d20f534
  1. 26
      src/components/chat/input.ts
  2. 4
      src/lang.ts
  3. 6
      src/lib/appManagers/appMessagesManager.ts

26
src/components/chat/input.ts

@ -45,7 +45,7 @@ import PopupPinMessage from '../popups/unpinMessage';
import { tsNow } from '../../helpers/date'; import { tsNow } from '../../helpers/date';
import appNavigationController from '../appNavigationController'; import appNavigationController from '../appNavigationController';
import { isMobile, isMobileSafari } from '../../helpers/userAgent'; 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 { generateTail } from './bubbles';
import findUpClassName from '../../helpers/dom/findUpClassName'; import findUpClassName from '../../helpers/dom/findUpClassName';
import ButtonCorner from '../buttonCorner'; import ButtonCorner from '../buttonCorner';
@ -816,14 +816,34 @@ export default class ChatInput {
} }
public updateMessageInput() { 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.add('no-transition');
this.chatInput.classList.toggle('is-hidden', !canWrite); this.chatInput.classList.toggle('is-hidden', !canWrite);
void this.chatInput.offsetLeft; // reflow void this.chatInput.offsetLeft; // reflow
this.chatInput.classList.remove('no-transition'); 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 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); button.element.classList.toggle('hide', !good);
return good; return good;
}); });

4
src/lang.ts

@ -568,6 +568,10 @@ const lang = {
"ShareContact": "Share contact", "ShareContact": "Share contact",
"SendMessageTitle": "Send message", "SendMessageTitle": "Send message",
"SendContactToGroupText": "Do you want to send this contact to **%1$s**?", "SendContactToGroupText": "Do you want to send this contact to **%1$s**?",
"ChannelBroadcast": "Broadcast",
"ChannelSilentBroadcast": "Silent Broadcast",
"Comment": "Comment",
"SendAnonymously": "Send anonymously",
// * macos // * macos
"AccountSettings.Filters": "Chat Folders", "AccountSettings.Filters": "Chat Folders",

6
src/lib/appManagers/appMessagesManager.ts

@ -1509,7 +1509,7 @@ export class AppMessagesManager {
* Generate correct from_id according to anonymous or broadcast * Generate correct from_id according to anonymous or broadcast
*/ */
private generateFromId(peerId: number) { 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; return undefined;
} else { } else {
return appPeersManager.getOutputPeer(appUsersManager.getSelf().id); return appPeersManager.getOutputPeer(appUsersManager.getSelf().id);
@ -1590,6 +1590,10 @@ export class AppMessagesManager {
return message; 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)) { public setDialogTopMessage(message: MyMessage, dialog: MTDialog.dialog = this.getDialogOnly(message.peerId)) {
if(dialog) { if(dialog) {
dialog.top_message = message.mid; dialog.top_message = message.mid;

Loading…
Cancel
Save