@@ -14,7 +14,7 @@ import {Chat, ChatFull, ChatParticipants} from '../../../layer';
1414import AppChatTypeTab from './chatType' ;
1515import rootScope from '../../../lib/rootScope' ;
1616import AppGroupPermissionsTab from './groupPermissions' ;
17- import I18n , { i18n , LangPackKey } from '../../../lib/langPack' ;
17+ import { i18n , LangPackKey } from '../../../lib/langPack' ;
1818import PopupDeleteDialog from '../../popups/deleteDialog' ;
1919import { attachClickEvent } from '../../../helpers/dom/clickEvent' ;
2020import toggleDisability from '../../../helpers/dom/toggleDisability' ;
@@ -35,7 +35,6 @@ import cancelEvent from '../../../helpers/dom/cancelEvent';
3535import { toastNew } from '../../toast' ;
3636import AppChatInviteLinksTab from './chatInviteLinks' ;
3737import AppChatRequestsTab from './chatRequests' ;
38- import { SliderSuperTabConstructable } from '../../sliderTab' ;
3938
4039export default class AppEditChatTab extends SliderSuperTab {
4140 private chatNameInputField : InputField ;
@@ -61,6 +60,9 @@ export default class AppEditChatTab extends SliderSuperTab {
6160 canManageAdmins ,
6261 canChangeInfo ,
6362 canDeleteChat ,
63+ canPostMessages ,
64+ canManageInviteLinks ,
65+ canInviteUsers ,
6466 appConfig ,
6567 availableReactions
6668 ] = await Promise . all ( [
@@ -74,6 +76,9 @@ export default class AppEditChatTab extends SliderSuperTab {
7476 this . managers . appChatsManager . hasRights ( this . chatId , 'change_permissions' ) ,
7577 this . managers . appChatsManager . hasRights ( this . chatId , 'change_info' ) ,
7678 this . managers . appChatsManager . hasRights ( this . chatId , 'delete_chat' ) ,
79+ this . managers . appChatsManager . hasRights ( this . chatId , 'post_messages' ) ,
80+ this . managers . appChatsManager . hasRights ( this . chatId , 'invite_links' ) ,
81+ this . managers . appChatsManager . hasRights ( this . chatId , 'invite_users' ) ,
7782 this . managers . apiManager . getAppConfig ( ) ,
7883 this . managers . appReactionsManager . getAvailableReactions ( )
7984 ] ) ;
@@ -102,6 +107,7 @@ export default class AppEditChatTab extends SliderSuperTab {
102107 } ) ;
103108
104109 const peerId = this . chatId . toPeerId ( true ) ;
110+ const isAdmin = ! ! chat . admin_rights ;
105111
106112 {
107113 const section = new SettingSection ( { noDelimiter : true , caption : 'PeerInfo.SetAboutDescription' } ) ;
@@ -114,13 +120,15 @@ export default class AppEditChatTab extends SliderSuperTab {
114120 label : isBroadcast ? 'EnterChannelName' : 'CreateGroup.NameHolder' ,
115121 name : 'chat-name' ,
116122 maxLength : 255 ,
117- required : true
123+ required : true ,
124+ canBeEdited : canChangeInfo
118125 } ) ;
119126 this . descriptionInputField = new InputField ( {
120127 label : 'DescriptionPlaceholder' ,
121128 name : 'chat-description' ,
122129 maxLength : 255 ,
123- withLinebreaks : true
130+ withLinebreaks : true ,
131+ canBeEdited : canChangeInfo
124132 } ) ;
125133
126134 this . chatNameInputField . setOriginalValue ( chat . title ) ;
@@ -139,6 +147,12 @@ export default class AppEditChatTab extends SliderSuperTab {
139147 } ) ;
140148 this . content . append ( this . editPeer . nextBtn ) ;
141149
150+ if ( ! canChangeInfo ) {
151+ this . editPeer . avatarElem . node . classList . remove ( 'avatar-placeholder' ) ;
152+ this . editPeer . avatarEdit . container . replaceChildren ( this . editPeer . avatarElem . node ) ;
153+ this . editPeer . avatarEdit . container . classList . add ( 'disable-hover' ) ;
154+ }
155+
142156 section . content . append ( this . editPeer . avatarEdit . container , inputWrapper ) ;
143157 this . scrollable . append ( section . container ) ;
144158 }
@@ -176,7 +190,7 @@ export default class AppEditChatTab extends SliderSuperTab {
176190 section . content . append ( chatTypeRow . container ) ;
177191 }
178192
179- {
193+ if ( canManageInviteLinks ) {
180194 const inviteLinksRow = new Row ( {
181195 titleLangKey : 'InviteLinks' ,
182196 navigationTab : {
@@ -202,7 +216,7 @@ export default class AppEditChatTab extends SliderSuperTab {
202216 section . content . append ( inviteLinksRow . container ) ;
203217 }
204218
205- {
219+ if ( canInviteUsers && isAdmin ) {
206220 const requestsRow = new Row ( {
207221 titleLangKey : isBroadcast ? 'SubscribeRequests' : 'MemberRequests' ,
208222 navigationTab : {
@@ -227,7 +241,8 @@ export default class AppEditChatTab extends SliderSuperTab {
227241 section . content . append ( requestsRow . container ) ;
228242 }
229243
230- if ( canChangeType || canChangePermissions ) {
244+ // if(canChangeType || canChangePermissions) {
245+ if ( canChangeInfo && isAdmin ) {
231246 const reactionsRow = new Row ( {
232247 titleLangKey : 'Reactions' ,
233248 icon : 'reactions' ,
@@ -262,7 +277,44 @@ export default class AppEditChatTab extends SliderSuperTab {
262277 section . content . append ( reactionsRow . container ) ;
263278 }
264279
265- if ( canChangeType ) {
280+ if ( canChangePermissions && ! isBroadcast ) {
281+ const flags = [
282+ 'send_stickers' ,
283+ 'send_polls' ,
284+ 'send_photos' ,
285+ 'send_videos' ,
286+ 'send_roundvideos' ,
287+ 'send_audios' ,
288+ 'send_voices' ,
289+ 'send_docs' ,
290+ 'send_plain' ,
291+ 'embed_links' ,
292+ 'invite_users' ,
293+ 'pin_messages' ,
294+ 'change_info'
295+ ] as ChatRights [ ] ;
296+
297+ const permissionsRow = new Row ( {
298+ titleLangKey : 'ChannelPermissions' ,
299+ clickable : ( ) => {
300+ const tab = this . slider . createTab ( AppGroupPermissionsTab ) ;
301+ tab . chatId = this . chatId ;
302+ tab . open ( ) ;
303+ } ,
304+ icon : 'permissions' ,
305+ listenerSetter : this . listenerSetter
306+ } ) ;
307+
308+ const setPermissionsLength = ( ) => {
309+ permissionsRow . subtitle . textContent = flags . reduce ( ( acc , f ) => acc + + hasRights ( chat , f , ( chat as Chat . chat ) . default_banned_rights ) , 0 ) + '/' + flags . length ;
310+ } ;
311+
312+ setPermissionsLength ( ) ;
313+ addChatUpdateListener ( setPermissionsLength ) ;
314+ section . content . append ( permissionsRow . container ) ;
315+ }
316+
317+ if ( canChangeInfo && isAdmin ) {
266318 const discussionRow = new Row ( {
267319 icon : 'comments' ,
268320 titleLangKey : isBroadcast ? 'PeerInfo.Discussion' : 'LinkedChannel' ,
@@ -302,43 +354,6 @@ export default class AppEditChatTab extends SliderSuperTab {
302354 section . content . append ( discussionRow . container ) ;
303355 }
304356
305- if ( canChangePermissions && ! isBroadcast ) {
306- const flags = [
307- 'send_stickers' ,
308- 'send_polls' ,
309- 'send_photos' ,
310- 'send_videos' ,
311- 'send_roundvideos' ,
312- 'send_audios' ,
313- 'send_voices' ,
314- 'send_docs' ,
315- 'send_plain' ,
316- 'embed_links' ,
317- 'invite_users' ,
318- 'pin_messages' ,
319- 'change_info'
320- ] as ChatRights [ ] ;
321-
322- const permissionsRow = new Row ( {
323- titleLangKey : 'ChannelPermissions' ,
324- clickable : ( ) => {
325- const tab = this . slider . createTab ( AppGroupPermissionsTab ) ;
326- tab . chatId = this . chatId ;
327- tab . open ( ) ;
328- } ,
329- icon : 'permissions' ,
330- listenerSetter : this . listenerSetter
331- } ) ;
332-
333- const setPermissionsLength = ( ) => {
334- permissionsRow . subtitle . textContent = flags . reduce ( ( acc , f ) => acc + + hasRights ( chat , f , ( chat as Chat . chat ) . default_banned_rights ) , 0 ) + '/' + flags . length ;
335- } ;
336-
337- setPermissionsLength ( ) ;
338- addChatUpdateListener ( setPermissionsLength ) ;
339- section . content . append ( permissionsRow . container ) ;
340- }
341-
342357 if ( canManageTopics && ( chat . participants_count >= appConfig . forum_upgrade_participants_min || ( chat as Chat . channel ) . pFlags . forum ) && ! isBroadcast ) {
343358 const topicsRow = new Row ( {
344359 checkboxField : new CheckboxField ( { toggle : true } ) ,
@@ -499,7 +514,7 @@ export default class AppEditChatTab extends SliderSuperTab {
499514 this . scrollable . append ( section . container ) ;
500515 }
501516
502- if ( isBroadcast && canChangeInfo ) {
517+ if ( isBroadcast && canPostMessages ) {
503518 const section = new SettingSection ( { caption : 'ChannelSignMessagesInfo' } ) ;
504519 const signMessagesCheckboxField = new CheckboxField ( {
505520 text : 'ChannelSignMessages' ,
0 commit comments