Channel type editing
This commit is contained in:
parent
a4b023a247
commit
a6fb84d550
@ -22,34 +22,37 @@ import I18n from "../../../lib/langPack";
|
|||||||
import PopupPeer from "../../popups/peer";
|
import PopupPeer from "../../popups/peer";
|
||||||
import ButtonCorner from "../../buttonCorner";
|
import ButtonCorner from "../../buttonCorner";
|
||||||
|
|
||||||
export default class AppGroupTypeTab extends SliderSuperTabEventable {
|
export default class AppChatTypeTab extends SliderSuperTabEventable {
|
||||||
public peerId: number;
|
public chatId: number;
|
||||||
public chatFull: ChatFull;
|
public chatFull: ChatFull;
|
||||||
|
|
||||||
protected init() {
|
protected init() {
|
||||||
this.container.classList.add('edit-peer-container', 'group-type-container');
|
this.container.classList.add('edit-peer-container', 'group-type-container');
|
||||||
this.setTitle('GroupType');
|
|
||||||
|
const isBroadcast = appChatsManager.isBroadcast(this.chatId);
|
||||||
|
|
||||||
|
this.setTitle(isBroadcast ? 'ChannelType' : 'GroupType');
|
||||||
|
|
||||||
const section = new SettingSection({
|
const section = new SettingSection({
|
||||||
name: 'GroupType'
|
name: isBroadcast ? 'ChannelType' : 'GroupType'
|
||||||
});
|
});
|
||||||
|
|
||||||
const random = randomLong();
|
const random = randomLong();
|
||||||
const privateRow = new Row({
|
const privateRow = new Row({
|
||||||
radioField: new RadioField({
|
radioField: new RadioField({
|
||||||
langKey: 'MegaPrivate',
|
langKey: isBroadcast ? 'ChannelPrivate' : 'MegaPrivate',
|
||||||
name: random,
|
name: random,
|
||||||
value: 'private'
|
value: 'private'
|
||||||
}),
|
}),
|
||||||
subtitleLangKey: 'MegaPrivateInfo'
|
subtitleLangKey: isBroadcast ? 'ChannelPrivateInfo' : 'MegaPrivateInfo'
|
||||||
});
|
});
|
||||||
const publicRow = new Row({
|
const publicRow = new Row({
|
||||||
radioField: new RadioField({
|
radioField: new RadioField({
|
||||||
langKey: 'MegaPublic',
|
langKey: isBroadcast ? 'ChannelPublic' : 'MegaPublic',
|
||||||
name: random,
|
name: random,
|
||||||
value: 'public'
|
value: 'public'
|
||||||
}),
|
}),
|
||||||
subtitleLangKey: 'MegaPublicInfo'
|
subtitleLangKey: isBroadcast ? 'ChannelPublicInfo' : 'MegaPublicInfo'
|
||||||
});
|
});
|
||||||
const form = RadioFormFromRows([privateRow, publicRow], (value) => {
|
const form = RadioFormFromRows([privateRow, publicRow], (value) => {
|
||||||
const a = [privateSection, publicSection];
|
const a = [privateSection, publicSection];
|
||||||
@ -61,7 +64,7 @@ export default class AppGroupTypeTab extends SliderSuperTabEventable {
|
|||||||
onChange();
|
onChange();
|
||||||
});
|
});
|
||||||
|
|
||||||
const chat: Chat = appChatsManager.getChat(-this.peerId);
|
const chat: Chat = appChatsManager.getChat(this.chatId);
|
||||||
|
|
||||||
section.content.append(form);
|
section.content.append(form);
|
||||||
|
|
||||||
@ -70,7 +73,7 @@ export default class AppGroupTypeTab extends SliderSuperTabEventable {
|
|||||||
//let revoked = false;
|
//let revoked = false;
|
||||||
const linkRow = new Row({
|
const linkRow = new Row({
|
||||||
title: (this.chatFull.exported_invite as ExportedChatInvite.chatInviteExported).link,
|
title: (this.chatFull.exported_invite as ExportedChatInvite.chatInviteExported).link,
|
||||||
subtitleLangKey: 'MegaPrivateLinkHelp',
|
subtitleLangKey: isBroadcast ? 'ChannelPrivateLinkHelp' : 'MegaPrivateLinkHelp',
|
||||||
clickable: () => {
|
clickable: () => {
|
||||||
copyTextToClipboard((this.chatFull.exported_invite as ExportedChatInvite.chatInviteExported).link);
|
copyTextToClipboard((this.chatFull.exported_invite as ExportedChatInvite.chatInviteExported).link);
|
||||||
toast(I18n.format('LinkCopied', true));
|
toast(I18n.format('LinkCopied', true));
|
||||||
@ -86,7 +89,7 @@ export default class AppGroupTypeTab extends SliderSuperTabEventable {
|
|||||||
callback: () => {
|
callback: () => {
|
||||||
const toggle = toggleDisability([btnRevoke], true);
|
const toggle = toggleDisability([btnRevoke], true);
|
||||||
|
|
||||||
appProfileManager.getChatInviteLink(-this.peerId, true).then(link => {
|
appProfileManager.getChatInviteLink(this.chatId, true).then(link => {
|
||||||
toggle();
|
toggle();
|
||||||
linkRow.title.innerHTML = link;
|
linkRow.title.innerHTML = link;
|
||||||
//revoked = true;
|
//revoked = true;
|
||||||
@ -102,7 +105,7 @@ export default class AppGroupTypeTab extends SliderSuperTabEventable {
|
|||||||
privateSection.content.append(linkRow.container, btnRevoke);
|
privateSection.content.append(linkRow.container, btnRevoke);
|
||||||
|
|
||||||
const publicSection = new SettingSection({
|
const publicSection = new SettingSection({
|
||||||
caption: 'Channel.UsernameAboutGroup',
|
caption: isBroadcast ? 'Channel.UsernameAboutChannel' : 'Channel.UsernameAboutGroup',
|
||||||
noDelimiter: true
|
noDelimiter: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -126,7 +129,7 @@ export default class AppGroupTypeTab extends SliderSuperTabEventable {
|
|||||||
invalidText: 'Link.Invalid',
|
invalidText: 'Link.Invalid',
|
||||||
takenText: 'Link.Taken',
|
takenText: 'Link.Taken',
|
||||||
onChange: onChange,
|
onChange: onChange,
|
||||||
peerId: this.peerId,
|
peerId: -this.chatId,
|
||||||
head: placeholder
|
head: placeholder
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -141,7 +144,7 @@ export default class AppGroupTypeTab extends SliderSuperTabEventable {
|
|||||||
attachClickEvent(applyBtn, () => {
|
attachClickEvent(applyBtn, () => {
|
||||||
/* const unsetLoader = */setButtonLoader(applyBtn);
|
/* const unsetLoader = */setButtonLoader(applyBtn);
|
||||||
const username = publicRow.radioField.checked ? linkInputField.getValue() : '';
|
const username = publicRow.radioField.checked ? linkInputField.getValue() : '';
|
||||||
appChatsManager.migrateChat(-this.peerId).then(channelId => {
|
appChatsManager.migrateChat(this.chatId).then(channelId => {
|
||||||
return appChatsManager.updateUsername(channelId, username);
|
return appChatsManager.updateUsername(channelId, username);
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
//unsetLoader();
|
//unsetLoader();
|
@ -1,199 +0,0 @@
|
|||||||
/*
|
|
||||||
* https://github.com/morethanwords/tweb
|
|
||||||
* Copyright (C) 2019-2021 Eduard Kuzmenko
|
|
||||||
* https://github.com/morethanwords/tweb/blob/master/LICENSE
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { SliderSuperTab } from "../../slider"
|
|
||||||
import InputField from "../../inputField";
|
|
||||||
import EditPeer from "../../editPeer";
|
|
||||||
import { SettingSection } from "../../sidebarLeft";
|
|
||||||
import Row from "../../row";
|
|
||||||
import CheckboxField from "../../checkboxField";
|
|
||||||
import Button from "../../button";
|
|
||||||
import appChatsManager from "../../../lib/appManagers/appChatsManager";
|
|
||||||
import appProfileManager from "../../../lib/appManagers/appProfileManager";
|
|
||||||
import { attachClickEvent, toggleDisability } from "../../../helpers/dom";
|
|
||||||
import PopupPeer from "../../popups/peer";
|
|
||||||
import { addCancelButton } from "../../popups";
|
|
||||||
import { i18n } from "../../../lib/langPack";
|
|
||||||
import { numberThousandSplitter } from "../../../helpers/number";
|
|
||||||
|
|
||||||
export default class AppEditChannelTab extends SliderSuperTab {
|
|
||||||
private nameInputField: InputField;
|
|
||||||
private descriptionInputField: InputField;
|
|
||||||
private editPeer: EditPeer;
|
|
||||||
public peerId: number;
|
|
||||||
|
|
||||||
protected async init() {
|
|
||||||
this.container.classList.add('edit-peer-container', 'edit-channel-container');
|
|
||||||
this.setTitle('Edit');
|
|
||||||
|
|
||||||
const chatFull = await appProfileManager.getChannelFull(-this.peerId, true);
|
|
||||||
|
|
||||||
{
|
|
||||||
const section = new SettingSection({noDelimiter: true});
|
|
||||||
|
|
||||||
if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
|
||||||
const inputFields: InputField[] = [];
|
|
||||||
|
|
||||||
const inputWrapper = document.createElement('div');
|
|
||||||
inputWrapper.classList.add('input-wrapper');
|
|
||||||
|
|
||||||
this.nameInputField = new InputField({
|
|
||||||
label: 'Channel.ChannelNameHolder',
|
|
||||||
name: 'channel-name',
|
|
||||||
maxLength: 255
|
|
||||||
});
|
|
||||||
this.descriptionInputField = new InputField({
|
|
||||||
label: 'DescriptionPlaceholder',
|
|
||||||
name: 'channel-description',
|
|
||||||
maxLength: 255
|
|
||||||
});
|
|
||||||
|
|
||||||
this.nameInputField.setOriginalValue(appChatsManager.getChat(-this.peerId).title);
|
|
||||||
|
|
||||||
this.descriptionInputField.setOriginalValue(chatFull.about);
|
|
||||||
|
|
||||||
inputWrapper.append(this.nameInputField.container, this.descriptionInputField.container);
|
|
||||||
|
|
||||||
inputFields.push(this.nameInputField, this.descriptionInputField);
|
|
||||||
|
|
||||||
this.editPeer = new EditPeer({
|
|
||||||
peerId: this.peerId,
|
|
||||||
inputFields,
|
|
||||||
listenerSetter: this.listenerSetter
|
|
||||||
});
|
|
||||||
this.content.append(this.editPeer.nextBtn);
|
|
||||||
|
|
||||||
section.content.append(this.editPeer.avatarEdit.container, inputWrapper);
|
|
||||||
|
|
||||||
attachClickEvent(this.editPeer.nextBtn, () => {
|
|
||||||
this.editPeer.nextBtn.disabled = true;
|
|
||||||
|
|
||||||
let promises: Promise<any>[] = [];
|
|
||||||
|
|
||||||
const id = -this.peerId;
|
|
||||||
if(this.nameInputField.isValid()) {
|
|
||||||
promises.push(appChatsManager.editTitle(id, this.nameInputField.value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.descriptionInputField.isValid()) {
|
|
||||||
promises.push(appChatsManager.editAbout(id, this.descriptionInputField.value));
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.editPeer.uploadAvatar) {
|
|
||||||
promises.push(this.editPeer.uploadAvatar().then(inputFile => {
|
|
||||||
return appChatsManager.editPhoto(id, inputFile);
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
Promise.race(promises).finally(() => {
|
|
||||||
this.editPeer.nextBtn.removeAttribute('disabled');
|
|
||||||
this.close();
|
|
||||||
});
|
|
||||||
}, {listenerSetter: this.listenerSetter});
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if(appChatsManager.hasRights(-this.peerId, 'change_type')) {
|
|
||||||
const channelTypeRow = new Row({
|
|
||||||
titleLangKey: 'ChannelType',
|
|
||||||
subtitleLangKey: 'TypePrivate',
|
|
||||||
clickable: true,
|
|
||||||
icon: 'lock'
|
|
||||||
});
|
|
||||||
|
|
||||||
section.content.append(channelTypeRow.container);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
|
||||||
const discussionRow = new Row({
|
|
||||||
titleLangKey: 'PeerInfo.Discussion',
|
|
||||||
subtitleLangKey: 'PeerInfo.Discussion.Add',
|
|
||||||
clickable: true,
|
|
||||||
icon: 'message'
|
|
||||||
});
|
|
||||||
|
|
||||||
section.content.append(discussionRow.container);
|
|
||||||
}
|
|
||||||
|
|
||||||
const administratorsRow = new Row({
|
|
||||||
titleLangKey: 'PeerInfo.Administrators',
|
|
||||||
subtitle: '' + chatFull.admins_count,
|
|
||||||
icon: 'admin',
|
|
||||||
clickable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
section.content.append(administratorsRow.container);
|
|
||||||
|
|
||||||
if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
|
||||||
const signMessagesCheckboxField = new CheckboxField({
|
|
||||||
text: 'PeerInfo.SignMessages',
|
|
||||||
checked: false
|
|
||||||
});
|
|
||||||
|
|
||||||
section.content.append(signMessagesCheckboxField.label);
|
|
||||||
} */
|
|
||||||
|
|
||||||
this.scrollable.append(section.container);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* {
|
|
||||||
const section = new SettingSection({
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
const subscribersRow = new Row({
|
|
||||||
titleLangKey: 'PeerInfo.Subscribers',
|
|
||||||
icon: 'newgroup',
|
|
||||||
clickable: true
|
|
||||||
});
|
|
||||||
|
|
||||||
subscribersRow.subtitle.append(i18n('Subscribers', [numberThousandSplitter(335356)]));
|
|
||||||
|
|
||||||
section.content.append(subscribersRow.container);
|
|
||||||
|
|
||||||
this.scrollable.append(section.container);
|
|
||||||
} */
|
|
||||||
|
|
||||||
if(appChatsManager.hasRights(-this.peerId, 'delete_chat')) {
|
|
||||||
const section = new SettingSection({
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
const btnDelete = Button('btn-primary btn-transparent danger', {icon: 'delete', text: 'PeerInfo.DeleteChannel'});
|
|
||||||
|
|
||||||
attachClickEvent(btnDelete, () => {
|
|
||||||
new PopupPeer('popup-delete-channel', {
|
|
||||||
peerId: this.peerId,
|
|
||||||
titleLangKey: 'ChannelDeleteMenu',
|
|
||||||
descriptionLangKey: 'AreYouSureDeleteAndExitChannel',
|
|
||||||
buttons: addCancelButton([{
|
|
||||||
langKey: 'ChannelDeleteMenu',
|
|
||||||
callback: () => {
|
|
||||||
const toggle = toggleDisability([btnDelete], true);
|
|
||||||
|
|
||||||
},
|
|
||||||
isDanger: true
|
|
||||||
}, {
|
|
||||||
langKey: 'DeleteChannelForAll',
|
|
||||||
callback: () => {
|
|
||||||
const toggle = toggleDisability([btnDelete], true);
|
|
||||||
|
|
||||||
appChatsManager.deleteChannel(-this.peerId).then(() => {
|
|
||||||
this.close();
|
|
||||||
}, () => {
|
|
||||||
toggle();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
isDanger: true
|
|
||||||
}])
|
|
||||||
}).show();
|
|
||||||
}, {listenerSetter: this.listenerSetter});
|
|
||||||
|
|
||||||
section.content.append(btnDelete);
|
|
||||||
|
|
||||||
this.scrollable.append(section.container);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -13,15 +13,17 @@ import Button from "../../button";
|
|||||||
import appChatsManager, { ChatRights } from "../../../lib/appManagers/appChatsManager";
|
import appChatsManager, { ChatRights } from "../../../lib/appManagers/appChatsManager";
|
||||||
import appProfileManager from "../../../lib/appManagers/appProfileManager";
|
import appProfileManager from "../../../lib/appManagers/appProfileManager";
|
||||||
import { attachClickEvent, toggleDisability } from "../../../helpers/dom";
|
import { attachClickEvent, toggleDisability } from "../../../helpers/dom";
|
||||||
import { ChatFull } from "../../../layer";
|
import { Chat } from "../../../layer";
|
||||||
import AppGroupTypeTab from "./groupType";
|
import AppChatTypeTab from "./chatType";
|
||||||
import rootScope from "../../../lib/rootScope";
|
import rootScope from "../../../lib/rootScope";
|
||||||
import AppGroupPermissionsTab from "./groupPermissions";
|
import AppGroupPermissionsTab from "./groupPermissions";
|
||||||
import { i18n } from "../../../lib/langPack";
|
import { i18n, LangPackKey } from "../../../lib/langPack";
|
||||||
import PopupDeleteDialog from "../../popups/deleteDialog";
|
import PopupDeleteDialog from "../../popups/deleteDialog";
|
||||||
|
import { addCancelButton } from "../../popups";
|
||||||
|
import PopupPeer from "../../popups/peer";
|
||||||
|
|
||||||
export default class AppEditGroupTab extends SliderSuperTab {
|
export default class AppEditChatTab extends SliderSuperTab {
|
||||||
private groupNameInputField: InputField;
|
private chatNameInputField: InputField;
|
||||||
private descriptionInputField: InputField;
|
private descriptionInputField: InputField;
|
||||||
private editPeer: EditPeer;
|
private editPeer: EditPeer;
|
||||||
public chatId: number;
|
public chatId: number;
|
||||||
@ -33,9 +35,13 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
|
|
||||||
this.container.classList.add('edit-peer-container', 'edit-group-container');
|
this.container.classList.add('edit-peer-container', 'edit-group-container');
|
||||||
this.setTitle('Edit');
|
this.setTitle('Edit');
|
||||||
|
|
||||||
const chatFull = await appProfileManager.getChatFull(this.chatId, true);
|
const chatFull = await appProfileManager.getChatFull(this.chatId, true);
|
||||||
|
|
||||||
|
const chat: Chat.chat | Chat.channel = appChatsManager.getChat(this.chatId);
|
||||||
|
const isBroadcast = appChatsManager.isBroadcast(this.chatId);
|
||||||
|
const isChannel = appChatsManager.isChannel(this.chatId);
|
||||||
|
|
||||||
{
|
{
|
||||||
const section = new SettingSection({noDelimiter: true});
|
const section = new SettingSection({noDelimiter: true});
|
||||||
const inputFields: InputField[] = [];
|
const inputFields: InputField[] = [];
|
||||||
@ -43,26 +49,23 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
const inputWrapper = document.createElement('div');
|
const inputWrapper = document.createElement('div');
|
||||||
inputWrapper.classList.add('input-wrapper');
|
inputWrapper.classList.add('input-wrapper');
|
||||||
|
|
||||||
this.groupNameInputField = new InputField({
|
this.chatNameInputField = new InputField({
|
||||||
label: 'CreateGroup.NameHolder',
|
label: isBroadcast ? 'Channel.ChannelNameHolder' : 'CreateGroup.NameHolder',
|
||||||
name: 'group-name',
|
name: 'chat-name',
|
||||||
maxLength: 255
|
maxLength: 255
|
||||||
});
|
});
|
||||||
this.descriptionInputField = new InputField({
|
this.descriptionInputField = new InputField({
|
||||||
label: 'DescriptionPlaceholder',
|
label: 'DescriptionPlaceholder',
|
||||||
name: 'group-description',
|
name: 'chat-description',
|
||||||
maxLength: 255
|
maxLength: 255
|
||||||
});
|
});
|
||||||
|
|
||||||
const chat = appChatsManager.getChat(this.chatId);
|
|
||||||
|
|
||||||
this.groupNameInputField.setOriginalValue(chat.title);
|
this.chatNameInputField.setOriginalValue(chat.title);
|
||||||
|
|
||||||
this.descriptionInputField.setOriginalValue(chatFull.about);
|
this.descriptionInputField.setOriginalValue(chatFull.about);
|
||||||
|
|
||||||
inputWrapper.append(this.groupNameInputField.container, this.descriptionInputField.container);
|
inputWrapper.append(this.chatNameInputField.container, this.descriptionInputField.container);
|
||||||
|
|
||||||
inputFields.push(this.groupNameInputField, this.descriptionInputField);
|
inputFields.push(this.chatNameInputField, this.descriptionInputField);
|
||||||
|
|
||||||
this.editPeer = new EditPeer({
|
this.editPeer = new EditPeer({
|
||||||
peerId: -this.chatId,
|
peerId: -this.chatId,
|
||||||
@ -74,29 +77,37 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
section.content.append(this.editPeer.avatarEdit.container, inputWrapper);
|
section.content.append(this.editPeer.avatarEdit.container, inputWrapper);
|
||||||
|
|
||||||
if(appChatsManager.hasRights(this.chatId, 'change_type')) {
|
if(appChatsManager.hasRights(this.chatId, 'change_type')) {
|
||||||
const groupTypeRow = new Row({
|
const chatTypeRow = new Row({
|
||||||
titleLangKey: 'GroupType',
|
titleLangKey: isBroadcast ? 'ChannelType' : 'GroupType',
|
||||||
clickable: () => {
|
clickable: () => {
|
||||||
const tab = new AppGroupTypeTab(this.slider);
|
const tab = new AppChatTypeTab(this.slider);
|
||||||
tab.peerId = -this.chatId;
|
tab.chatId = this.chatId;
|
||||||
tab.chatFull = chatFull;
|
tab.chatFull = chatFull;
|
||||||
tab.open();
|
tab.open();
|
||||||
|
|
||||||
this.listenerSetter.add(tab.eventListener, 'destroy', setGroupTypeSubtitle);
|
this.listenerSetter.add(tab.eventListener, 'destroy', setChatTypeSubtitle);
|
||||||
},
|
},
|
||||||
icon: 'lock'
|
icon: 'lock'
|
||||||
});
|
});
|
||||||
|
|
||||||
const setGroupTypeSubtitle = () => {
|
const setChatTypeSubtitle = () => {
|
||||||
groupTypeRow.subtitle.textContent = '';
|
chatTypeRow.subtitle.textContent = '';
|
||||||
groupTypeRow.subtitle.append(i18n(chat.username ? 'TypePublicGroup' : 'TypePrivateGroup'));
|
|
||||||
|
let key: LangPackKey;
|
||||||
|
if(isBroadcast) {
|
||||||
|
key = (chat as Chat.channel).username ? 'TypePublic' : 'TypePrivate';
|
||||||
|
} else {
|
||||||
|
key = (chat as Chat.channel).username ? 'TypePublicGroup' : 'TypePrivateGroup';
|
||||||
|
}
|
||||||
|
|
||||||
|
chatTypeRow.subtitle.append(i18n(key));
|
||||||
};
|
};
|
||||||
|
|
||||||
setGroupTypeSubtitle();
|
setChatTypeSubtitle();
|
||||||
section.content.append(groupTypeRow.container);
|
section.content.append(chatTypeRow.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(appChatsManager.hasRights(this.chatId, 'change_permissions')) {
|
if(appChatsManager.hasRights(this.chatId, 'change_permissions') && !isBroadcast) {
|
||||||
const flags = [
|
const flags = [
|
||||||
'send_messages',
|
'send_messages',
|
||||||
'send_media',
|
'send_media',
|
||||||
@ -149,8 +160,8 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
let promises: Promise<any>[] = [];
|
let promises: Promise<any>[] = [];
|
||||||
|
|
||||||
const id = this.chatId;
|
const id = this.chatId;
|
||||||
if(this.groupNameInputField.isValid()) {
|
if(this.chatNameInputField.isValid()) {
|
||||||
promises.push(appChatsManager.editTitle(id, this.groupNameInputField.value));
|
promises.push(appChatsManager.editTitle(id, this.chatNameInputField.value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(this.descriptionInputField.isValid()) {
|
if(this.descriptionInputField.isValid()) {
|
||||||
@ -168,6 +179,36 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
this.close();
|
this.close();
|
||||||
});
|
});
|
||||||
}, {listenerSetter: this.listenerSetter});
|
}, {listenerSetter: this.listenerSetter});
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
||||||
|
const discussionRow = new Row({
|
||||||
|
titleLangKey: 'PeerInfo.Discussion',
|
||||||
|
subtitleLangKey: 'PeerInfo.Discussion.Add',
|
||||||
|
clickable: true,
|
||||||
|
icon: 'message'
|
||||||
|
});
|
||||||
|
|
||||||
|
section.content.append(discussionRow.container);
|
||||||
|
}
|
||||||
|
|
||||||
|
const administratorsRow = new Row({
|
||||||
|
titleLangKey: 'PeerInfo.Administrators',
|
||||||
|
subtitle: '' + chatFull.admins_count,
|
||||||
|
icon: 'admin',
|
||||||
|
clickable: true
|
||||||
|
});
|
||||||
|
|
||||||
|
section.content.append(administratorsRow.container);
|
||||||
|
|
||||||
|
if(appChatsManager.hasRights(-this.peerId, 'change_info')) {
|
||||||
|
const signMessagesCheckboxField = new CheckboxField({
|
||||||
|
text: 'PeerInfo.SignMessages',
|
||||||
|
checked: false
|
||||||
|
});
|
||||||
|
|
||||||
|
section.content.append(signMessagesCheckboxField.label);
|
||||||
|
} */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* {
|
/* {
|
||||||
@ -176,12 +217,13 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const membersRow = new Row({
|
const membersRow = new Row({
|
||||||
titleLangKey: 'GroupMembers',
|
titleLangKey: isBroadcast ? 'PeerInfo.Subscribers' : 'GroupMembers',
|
||||||
subtitle: '2 500',
|
|
||||||
icon: 'newgroup',
|
icon: 'newgroup',
|
||||||
clickable: true
|
clickable: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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(appChatsManager.hasRights(this.chatId, 'change_permissions')) {
|
||||||
@ -203,17 +245,45 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
if(appChatsManager.hasRights(this.chatId, 'delete_chat')) {
|
if(appChatsManager.hasRights(this.chatId, 'delete_chat')) {
|
||||||
const section = new SettingSection({});
|
const section = new SettingSection({});
|
||||||
|
|
||||||
const btnDelete = Button('btn-primary btn-transparent danger', {icon: 'delete', text: 'DeleteMega'});
|
const btnDelete = Button('btn-primary btn-transparent danger', {icon: 'delete', text: isBroadcast ? 'PeerInfo.DeleteChannel' : 'DeleteMega'});
|
||||||
|
|
||||||
attachClickEvent(btnDelete, () => {
|
attachClickEvent(btnDelete, () => {
|
||||||
new PopupDeleteDialog(-this.chatId, undefined, (promise) => {
|
if(isBroadcast) {
|
||||||
const toggle = toggleDisability([btnDelete], true);
|
new PopupPeer('popup-delete-channel', {
|
||||||
promise.then(() => {
|
peerId: -this.chatId,
|
||||||
this.close();
|
titleLangKey: 'ChannelDeleteMenu',
|
||||||
}, () => {
|
descriptionLangKey: 'AreYouSureDeleteAndExitChannel',
|
||||||
toggle();
|
buttons: addCancelButton([{
|
||||||
|
langKey: 'ChannelDeleteMenu',
|
||||||
|
callback: () => {
|
||||||
|
const toggle = toggleDisability([btnDelete], true);
|
||||||
|
|
||||||
|
},
|
||||||
|
isDanger: true
|
||||||
|
}, {
|
||||||
|
langKey: 'DeleteChannelForAll',
|
||||||
|
callback: () => {
|
||||||
|
const toggle = toggleDisability([btnDelete], true);
|
||||||
|
|
||||||
|
appChatsManager.deleteChannel(this.chatId).then(() => {
|
||||||
|
this.close();
|
||||||
|
}, () => {
|
||||||
|
toggle();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
isDanger: true
|
||||||
|
}])
|
||||||
|
}).show();
|
||||||
|
} else {
|
||||||
|
new PopupDeleteDialog(-this.chatId, undefined, (promise) => {
|
||||||
|
const toggle = toggleDisability([btnDelete], true);
|
||||||
|
promise.then(() => {
|
||||||
|
this.close();
|
||||||
|
}, () => {
|
||||||
|
toggle();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}, {listenerSetter: this.listenerSetter});
|
}, {listenerSetter: this.listenerSetter});
|
||||||
|
|
||||||
section.content.append(btnDelete);
|
section.content.append(btnDelete);
|
||||||
@ -221,13 +291,15 @@ export default class AppEditGroupTab extends SliderSuperTab {
|
|||||||
this.scrollable.append(section.container);
|
this.scrollable.append(section.container);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ! this one will fire earlier than tab's closeAfterTimeout (destroy) event and listeners will be erased, so destroy won't fire
|
if(!isChannel) {
|
||||||
this.listenerSetter.add(rootScope, 'dialog_migrate', ({migrateFrom, migrateTo}) => {
|
// ! this one will fire earlier than tab's closeAfterTimeout (destroy) event and listeners will be erased, so destroy won't fire
|
||||||
if(-this.chatId === migrateFrom) {
|
this.listenerSetter.add(rootScope, 'dialog_migrate', ({migrateFrom, migrateTo}) => {
|
||||||
this.chatId = -migrateTo;
|
if(-this.chatId === migrateFrom) {
|
||||||
this._init();
|
this.chatId = -migrateTo;
|
||||||
}
|
this._init();
|
||||||
});
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected init() {
|
protected init() {
|
@ -19,9 +19,8 @@ import { attachClickEvent, replaceContent, cancelEvent } from "../../../helpers/
|
|||||||
import appSidebarRight from "..";
|
import appSidebarRight from "..";
|
||||||
import { TransitionSlider } from "../../transition";
|
import { TransitionSlider } from "../../transition";
|
||||||
import appNotificationsManager from "../../../lib/appManagers/appNotificationsManager";
|
import appNotificationsManager from "../../../lib/appManagers/appNotificationsManager";
|
||||||
import AppEditGroupTab from "./editGroup";
|
import AppEditChatTab from "./editChat";
|
||||||
import PeerTitle from "../../peerTitle";
|
import PeerTitle from "../../peerTitle";
|
||||||
import AppEditChannelTab from "./editChannel";
|
|
||||||
import AppEditContactTab from "./editContact";
|
import AppEditContactTab from "./editContact";
|
||||||
import appChatsManager, { Channel } from "../../../lib/appManagers/appChatsManager";
|
import appChatsManager, { Channel } from "../../../lib/appManagers/appChatsManager";
|
||||||
import { Chat, Message, MessageAction, ChatFull, Photo } from "../../../layer";
|
import { Chat, Message, MessageAction, ChatFull, Photo } from "../../../layer";
|
||||||
@ -854,17 +853,15 @@ export default class AppSharedMediaTab extends SliderSuperTab {
|
|||||||
});
|
});
|
||||||
|
|
||||||
attachClickEvent(this.editBtn, (e) => {
|
attachClickEvent(this.editBtn, (e) => {
|
||||||
let tab: AppEditGroupTab | AppEditChannelTab | AppEditContactTab;
|
let tab: AppEditChatTab | AppEditContactTab;
|
||||||
if(appPeersManager.isAnyGroup(this.peerId)) {
|
if(this.peerId < 0) {
|
||||||
tab = new AppEditGroupTab(appSidebarRight);
|
tab = new AppEditChatTab(appSidebarRight);
|
||||||
} else if(this.peerId > 0) {
|
|
||||||
tab = new AppEditContactTab(appSidebarRight);
|
|
||||||
} else {
|
} else {
|
||||||
tab = new AppEditChannelTab(appSidebarRight);
|
tab = new AppEditContactTab(appSidebarRight);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(tab) {
|
if(tab) {
|
||||||
if(tab instanceof AppEditGroupTab) {
|
if(tab instanceof AppEditChatTab) {
|
||||||
tab.chatId = -this.peerId;
|
tab.chatId = -this.peerId;
|
||||||
} else {
|
} else {
|
||||||
tab.peerId = this.peerId;
|
tab.peerId = this.peerId;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user