Skip to content

Commit

Permalink
Fix admin rights setup
Browse files Browse the repository at this point in the history
  • Loading branch information
laktyushin committed Feb 20, 2021
1 parent 47677b6 commit 6ee581e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions submodules/PeerInfoUI/Sources/ChannelAdminController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -787,11 +787,16 @@ private func channelAdminControllerEntries(presentationData: PresentationData, s
} else {
currentRightsFlags = accountUserRightsFlags.subtracting(.canAddAdmins).subtracting(.canBeAnonymous)
}

var accountIsCreator = false
if case .creator = group.role {
accountIsCreator = true
}

var index = 0
for right in rightsOrder {
if accountUserRightsFlags.contains(right) {
entries.append(.rightItem(presentationData.theme, index, stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, defaultBannedRights: group.defaultBannedRights), right, currentRightsFlags, currentRightsFlags.contains(right), !state.updating))
entries.append(.rightItem(presentationData.theme, index, stringForRight(strings: presentationData.strings, right: right, isGroup: isGroup, defaultBannedRights: group.defaultBannedRights), right, currentRightsFlags, currentRightsFlags.contains(right), !state.updating && accountIsCreator))
index += 1
}
}
Expand Down Expand Up @@ -1101,9 +1106,9 @@ public func channelAdminController(context: AccountContext, peerId: PeerId, admi
}

if channel.flags.contains(.isCreator) {
updateFlags = maskRightsFlags.subtracting(.canAddAdmins)
updateFlags = maskRightsFlags.subtracting([.canAddAdmins, .canBeAnonymous])
} else if let adminRights = channel.adminRights {
updateFlags = maskRightsFlags.intersection(adminRights.rights).subtracting(.canAddAdmins)
updateFlags = maskRightsFlags.intersection(adminRights.rights).subtracting([.canAddAdmins, .canBeAnonymous])
} else {
updateFlags = []
}
Expand Down

0 comments on commit 6ee581e

Please sign in to comment.