Supported sending messages with signature
Toggle chat pre history hidden Toggle broadcast signatures
This commit is contained in:
parent
6ceaa261d6
commit
bd3eed26fb
@ -12,7 +12,7 @@ import Row from "../../row";
|
||||
import Button from "../../button";
|
||||
import appChatsManager, { ChatRights } from "../../../lib/appManagers/appChatsManager";
|
||||
import appProfileManager from "../../../lib/appManagers/appProfileManager";
|
||||
import { Chat } from "../../../layer";
|
||||
import { Chat, ChatFull } from "../../../layer";
|
||||
import AppChatTypeTab from "./chatType";
|
||||
import rootScope from "../../../lib/rootScope";
|
||||
import AppGroupPermissionsTab from "./groupPermissions";
|
||||
@ -22,6 +22,7 @@ import { addCancelButton } from "../../popups";
|
||||
import PopupPeer from "../../popups/peer";
|
||||
import { attachClickEvent } from "../../../helpers/dom/clickEvent";
|
||||
import toggleDisability from "../../../helpers/dom/toggleDisability";
|
||||
import CheckboxField from "../../checkboxField";
|
||||
|
||||
export default class AppEditChatTab extends SliderSuperTab {
|
||||
private chatNameInputField: InputField;
|
||||
@ -43,6 +44,17 @@ export default class AppEditChatTab extends SliderSuperTab {
|
||||
const isBroadcast = appChatsManager.isBroadcast(this.chatId);
|
||||
const isChannel = appChatsManager.isChannel(this.chatId);
|
||||
|
||||
const chatUpdateListeners: (() => void)[] = [];
|
||||
const addChatUpdateListener = (callback: () => void) => {
|
||||
chatUpdateListeners.push(callback);
|
||||
};
|
||||
|
||||
this.listenerSetter.add(rootScope)('chat_update', (chatId) => {
|
||||
if(this.chatId === chatId) {
|
||||
chatUpdateListeners.forEach(callback => callback());
|
||||
}
|
||||
});
|
||||
|
||||
{
|
||||
const section = new SettingSection({noDelimiter: true});
|
||||
const inputFields: InputField[] = [];
|
||||
@ -53,7 +65,8 @@ export default class AppEditChatTab extends SliderSuperTab {
|
||||
this.chatNameInputField = new InputField({
|
||||
label: isBroadcast ? 'Channel.ChannelNameHolder' : 'CreateGroup.NameHolder',
|
||||
name: 'chat-name',
|
||||
maxLength: 255
|
||||
maxLength: 255,
|
||||
required: true
|
||||
});
|
||||
this.descriptionInputField = new InputField({
|
||||
label: 'DescriptionPlaceholder',
|
||||
@ -181,8 +194,8 @@ export default class AppEditChatTab extends SliderSuperTab {
|
||||
});
|
||||
}, {listenerSetter: this.listenerSetter});
|
||||
|
||||
/*
|
||||
if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
||||
|
||||
/* if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
||||
const discussionRow = new Row({
|
||||
titleLangKey: 'PeerInfo.Discussion',
|
||||
subtitleLangKey: 'PeerInfo.Discussion.Add',
|
||||
@ -200,24 +213,36 @@ export default class AppEditChatTab extends SliderSuperTab {
|
||||
clickable: true
|
||||
});
|
||||
|
||||
section.content.append(administratorsRow.container);
|
||||
section.content.append(administratorsRow.container); */
|
||||
|
||||
if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
||||
if(isBroadcast && appChatsManager.hasRights(this.chatId, 'change_info')) {
|
||||
const signMessagesCheckboxField = new CheckboxField({
|
||||
text: 'PeerInfo.SignMessages',
|
||||
checked: false
|
||||
checked: !!(chat as Chat.channel).pFlags.signatures,
|
||||
withRipple: true
|
||||
});
|
||||
|
||||
this.listenerSetter.add(signMessagesCheckboxField.input)('change', () => {
|
||||
const toggle = signMessagesCheckboxField.toggleDisability(true);
|
||||
appChatsManager.toggleSignatures(this.chatId, signMessagesCheckboxField.checked).then(() => {
|
||||
toggle();
|
||||
});
|
||||
});
|
||||
|
||||
addChatUpdateListener(() => {
|
||||
signMessagesCheckboxField.setValueSilently(!!(chat as Chat.channel).pFlags.signatures);
|
||||
});
|
||||
|
||||
section.content.append(signMessagesCheckboxField.label);
|
||||
} */
|
||||
}
|
||||
}
|
||||
|
||||
/* {
|
||||
if(!isBroadcast) {
|
||||
const section = new SettingSection({
|
||||
|
||||
});
|
||||
|
||||
const membersRow = new Row({
|
||||
/* const membersRow = new Row({
|
||||
titleLangKey: isBroadcast ? 'PeerInfo.Subscribers' : 'GroupMembers',
|
||||
icon: 'newgroup',
|
||||
clickable: true
|
||||
@ -225,23 +250,31 @@ export default class AppEditChatTab extends SliderSuperTab {
|
||||
|
||||
membersRow.subtitle.append(i18n('Subscribers', [numberThousandSplitter(335356)]));
|
||||
|
||||
section.content.append(membersRow.container);
|
||||
section.content.append(membersRow.container); */
|
||||
|
||||
if(appChatsManager.hasRights(this.chatId, 'change_permissions')) {
|
||||
if(!isBroadcast && appChatsManager.hasRights(this.chatId, 'change_permissions')) {
|
||||
const showChatHistoryCheckboxField = new CheckboxField({
|
||||
text: 'Show chat history for new members',
|
||||
withRipple: true
|
||||
text: 'ChatHistory',
|
||||
withRipple: true,
|
||||
checked: !(chatFull as ChatFull.channelFull).pFlags.hidden_prehistory
|
||||
});
|
||||
|
||||
if(appChatsManager.isChannel(this.chatId) && !(chatFull as ChatFull.channelFull).pFlags.hidden_prehistory) {
|
||||
showChatHistoryCheckboxField.checked = true;
|
||||
}
|
||||
this.listenerSetter.add(showChatHistoryCheckboxField.input)('change', () => {
|
||||
const toggle = showChatHistoryCheckboxField.toggleDisability(true);
|
||||
appChatsManager.togglePreHistoryHidden(this.chatId, !showChatHistoryCheckboxField.checked).then(() => {
|
||||
toggle();
|
||||
});
|
||||
});
|
||||
|
||||
addChatUpdateListener(() => {
|
||||
showChatHistoryCheckboxField.setValueSilently(!(chatFull as ChatFull.channelFull).pFlags.hidden_prehistory);
|
||||
});
|
||||
|
||||
section.content.append(showChatHistoryCheckboxField.label);
|
||||
}
|
||||
|
||||
this.scrollable.append(section.container);
|
||||
} */
|
||||
}
|
||||
|
||||
if(appChatsManager.hasRights(this.chatId, 'delete_chat')) {
|
||||
const section = new SettingSection({});
|
||||
|
@ -561,6 +561,7 @@ const lang = {
|
||||
"ReportInfo": "Please enter any additional details relevant to your report.",
|
||||
"ReportSentInfo": "Telegram moderators will review your report.\nThank you for your cooperation!",
|
||||
"ReportHint": "Additional details...",
|
||||
"ChatHistory": "Chat history for new members",
|
||||
|
||||
// * macos
|
||||
"AccountSettings.Filters": "Chat Folders",
|
||||
|
@ -707,6 +707,26 @@ export class AppChatsManager {
|
||||
this.saveApiChats(messagesChats.chats);
|
||||
});
|
||||
}
|
||||
|
||||
public togglePreHistoryHidden(id: number, enabled: boolean) {
|
||||
return this.migrateChat(id).then(channelId => {
|
||||
return apiManager.invokeApi('channels.togglePreHistoryHidden', {
|
||||
channel: this.getChannelInput(channelId),
|
||||
enabled
|
||||
});
|
||||
}).then(updates => {
|
||||
apiUpdatesManager.processUpdateMessage(updates);
|
||||
});
|
||||
}
|
||||
|
||||
public toggleSignatures(id: number, enabled: boolean) {
|
||||
return apiManager.invokeApi('channels.toggleSignatures', {
|
||||
channel: this.getChannelInput(id),
|
||||
enabled
|
||||
}).then(updates => {
|
||||
apiUpdatesManager.processUpdateMessage(updates);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const appChatsManager = new AppChatsManager();
|
||||
|
@ -1415,11 +1415,23 @@ export class AppMessagesManager {
|
||||
options.replyToMsgId = options.threadId;
|
||||
}
|
||||
|
||||
let postAuthor: string;
|
||||
const isBroadcast = appPeersManager.isBroadcast(peerId);
|
||||
if(isBroadcast) {
|
||||
const chat = appPeersManager.getPeer(peerId) as Chat.channel;
|
||||
if(chat.pFlags.signatures) {
|
||||
const user = appUsersManager.getSelf();
|
||||
const fullName = user.first_name + (user.last_name ? ' ' + user.last_name : '');
|
||||
postAuthor = fullName;
|
||||
}
|
||||
}
|
||||
|
||||
const message: Message.message = {
|
||||
_: 'message',
|
||||
id: this.generateTempMessageId(peerId),
|
||||
from_id: this.generateFromId(peerId),
|
||||
peer_id: appPeersManager.getOutputPeer(peerId),
|
||||
post_author: postAuthor,
|
||||
pFlags: this.generateFlags(peerId),
|
||||
date: options.scheduleDate || (tsNow(true) + serverTimeManager.serverTimeOffset),
|
||||
message: '',
|
||||
@ -1429,7 +1441,7 @@ export class AppMessagesManager {
|
||||
via_bot_id: options.viaBotId,
|
||||
reply_markup: options.replyMarkup,
|
||||
replies: this.generateReplies(peerId),
|
||||
views: appPeersManager.isBroadcast(peerId) && 1,
|
||||
views: isBroadcast && 1,
|
||||
pending: true,
|
||||
};
|
||||
|
||||
|
@ -388,7 +388,7 @@ export class AppUsersManager {
|
||||
|| oldUser.sortName === undefined
|
||||
|| oldUser.first_name !== user.first_name
|
||||
|| oldUser.last_name !== user.last_name) {
|
||||
const fullName = user.first_name + ' ' + (user.last_name || '');
|
||||
const fullName = user.first_name + (user.last_name ? ' ' + user.last_name : '');
|
||||
|
||||
user.sortName = user.pFlags.deleted ? '' : cleanSearchText(fullName, false);
|
||||
user.initials = RichTextProcessor.getAbbreviation(fullName);
|
||||
|
Loading…
Reference in New Issue
Block a user