Various fixes

This commit is contained in:
Ilya Laktyushin
2023-02-28 20:48:06 +04:00
parent f6ff9b86d0
commit 5d25d2bb8a
11 changed files with 96 additions and 33 deletions

View File

@@ -547,6 +547,11 @@ private func channelPermissionsControllerEntries(context: AccountContext, presen
var entries: [ChannelPermissionsEntry] = []
if let channel = view.peers[view.peerId] as? TelegramChannel, let participants = participants, let cachedData = view.cachedData as? CachedChannelData, let defaultBannedRights = channel.defaultBannedRights {
var isDiscussion = false
if case .group = channel.info, case let .known(peerId) = cachedData.linkedDiscussionPeerId, peerId != nil {
isDiscussion = true
}
let effectiveRightsFlags: TelegramChatBannedRightsFlags
if let modifiedRightsFlags = state.modifiedRightsFlags {
effectiveRightsFlags = modifiedRightsFlags
@@ -558,7 +563,7 @@ private func channelPermissionsControllerEntries(context: AccountContext, presen
var rightIndex: Int = 0
for (rights, correspondingAdminRight) in allGroupPermissionList(peer: .channel(channel), expandMedia: false) {
var enabled = true
if channel.addressName != nil && publicGroupRestrictedPermissions.contains(rights) {
if (channel.addressName != nil || channel.flags.contains(.hasGeo) || isDiscussion) && publicGroupRestrictedPermissions.contains(rights) {
enabled = false
}
if !channel.hasPermission(.inviteMembers) {
@@ -938,7 +943,17 @@ public func channelPermissionsController(context: AccountContext, updatedPresent
} else if right.contains(.banAddMembers) {
text = presentationData.strings.GroupPermission_AddMembersNotAvailable
} else {
text = presentationData.strings.GroupPermission_NotAvailableInPublicGroups
var isDiscussion = false
if case .group = channel.info, let cachedData = view.cachedData as? CachedChannelData, case let .known(peerId) = cachedData.linkedDiscussionPeerId, peerId != nil {
isDiscussion = true
}
if channel.flags.contains(.hasGeo) {
text = presentationData.strings.GroupPermission_NotAvailableInGeoGroups
} else if isDiscussion {
text = presentationData.strings.GroupPermission_NotAvailableInDiscussionGroups
} else {
text = presentationData.strings.GroupPermission_NotAvailableInPublicGroups
}
}
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: text, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
break