Allow any group member to set member labels
This commit is contained in:
parent
d61dc14b7b
commit
90bbf7e76e
@ -197,11 +197,9 @@ class ContactAboutSheet: StackSheetViewController {
|
||||
stackView.addArrangedSubview(label)
|
||||
}
|
||||
|
||||
let canEditMemberLabel = groupViewHelper?.canEditConversationAttributes ?? false
|
||||
if
|
||||
BuildFlags.MemberLabel.send,
|
||||
isLocalUser,
|
||||
canEditMemberLabel,
|
||||
groupViewHelper?.canEditMemberLabels ?? false,
|
||||
let presenter = fromViewController as? MemberLabelViewControllerPresenter
|
||||
{
|
||||
stackView.addArrangedSubview(ProfileDetailLabel.memberLabel(memberLabel?.label, tapAction: { [weak self] in
|
||||
|
||||
@ -764,7 +764,7 @@ extension ConversationSettingsViewController {
|
||||
)
|
||||
}
|
||||
|
||||
let showAddMemberLabel = BuildFlags.MemberLabel.send && isLocalUser && memberLabel == nil && self.groupViewHelper.canEditConversationAttributes
|
||||
let showAddMemberLabel = isLocalUser && memberLabel == nil && self.groupViewHelper.canEditMemberLabels
|
||||
|
||||
section.add(OWSTableItem(customCellBlock: { [weak self] in
|
||||
guard let self else {
|
||||
@ -921,7 +921,7 @@ extension ConversationSettingsViewController {
|
||||
)
|
||||
|
||||
if BuildFlags.MemberLabel.send {
|
||||
let canEditMemberLabel = groupViewHelper.canEditConversationAttributes
|
||||
let canEditMemberLabel = groupViewHelper.canEditMemberLabels
|
||||
let iconColor: UIColor
|
||||
let textColor: UIColor
|
||||
if canEditMemberLabel {
|
||||
@ -946,12 +946,7 @@ extension ConversationSettingsViewController {
|
||||
memberLabelCoordinator?.presenter = self
|
||||
memberLabelCoordinator?.present()
|
||||
} else {
|
||||
presentToast(
|
||||
text: OWSLocalizedString(
|
||||
"MEMBER_LABEL_ADMIN_ONLY_WARNING_TOAST",
|
||||
comment: "Toast indicating that only admins can set a member label.",
|
||||
),
|
||||
)
|
||||
owsFailDebug("Unimplemented!")
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
@ -239,21 +239,9 @@ class GroupPermissionsSettingsViewController: OWSTableViewController2 {
|
||||
return
|
||||
}
|
||||
|
||||
let continueBlock = {
|
||||
self.newAccessAttributes = value
|
||||
self.updateTableContents()
|
||||
self.updateNavigation()
|
||||
}
|
||||
|
||||
switch value {
|
||||
case .administrator:
|
||||
showClearMemberLabelWarning(continueHandler: {
|
||||
continueBlock()
|
||||
})
|
||||
return
|
||||
case .member, .unknown, .any, .unsatisfiable:
|
||||
continueBlock()
|
||||
}
|
||||
self.newAccessAttributes = value
|
||||
self.updateTableContents()
|
||||
self.updateNavigation()
|
||||
}
|
||||
|
||||
private func tryToSetIsAnnouncementsOnly(_ value: Bool) {
|
||||
|
||||
@ -116,10 +116,7 @@ extension GroupViewHelper {
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func memberActionSheetRevokeGroupAdminWasSelected(
|
||||
address: SignalServiceAddress,
|
||||
hasMemberLabel: Bool,
|
||||
) {
|
||||
func memberActionSheetRevokeGroupAdminWasSelected(address: SignalServiceAddress) {
|
||||
let titleFormat = OWSLocalizedString(
|
||||
"CONVERSATION_SETTINGS_REVOKE_GROUP_ADMIN_TITLE_FORMAT",
|
||||
comment: "Format for title for 'revoke group admin' confirmation alert. Embeds {user to revoke admin status from}.",
|
||||
@ -129,23 +126,10 @@ extension GroupViewHelper {
|
||||
comment: "Label for 'revoke group admin' button in conversation settings view.",
|
||||
)
|
||||
|
||||
var message: String?
|
||||
if
|
||||
BuildFlags.MemberLabel.send,
|
||||
hasMemberLabel,
|
||||
let groupModel = (thread as? TSGroupThread)?.groupModel as? TSGroupModelV2,
|
||||
groupModel.access.attributes == .administrator
|
||||
{
|
||||
message = OWSLocalizedString(
|
||||
"CONVERSATION_SETTINGS_REVOKE_GROUP_ADMIN_MESSAGE",
|
||||
comment: "Message for 'revoke group admin' confirmation alert.",
|
||||
)
|
||||
}
|
||||
|
||||
showMemberActionConfirmationActionSheet(
|
||||
address: address,
|
||||
titleFormat: titleFormat,
|
||||
message: message,
|
||||
message: nil,
|
||||
actionTitle: actionTitle,
|
||||
updateDescription: "Revoke group admin",
|
||||
updateBlock: { (oldGroupModel, aci: Aci) in
|
||||
|
||||
@ -94,13 +94,19 @@ class GroupViewHelper {
|
||||
// * Group title (if group)
|
||||
// * Group avatar (if group)
|
||||
// * Pinned Messages (if group)
|
||||
// * Member Labels (if group)
|
||||
var canEditConversationAttributes: Bool {
|
||||
return canLocalUserEditConversation { groupAccess in
|
||||
return groupAccess.attributes
|
||||
}
|
||||
}
|
||||
|
||||
var canEditMemberLabels: Bool {
|
||||
guard BuildFlags.MemberLabel.send else {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// Can local user edit group membership.
|
||||
var canEditConversationMembership: Bool {
|
||||
return canLocalUserEditConversation { groupAccess in
|
||||
|
||||
@ -278,7 +278,6 @@ class MemberActionSheet: OWSTableSheetViewController {
|
||||
self.dismiss(animated: true) {
|
||||
self.groupViewHelper?.memberActionSheetRevokeGroupAdminWasSelected(
|
||||
address: self.address,
|
||||
hasMemberLabel: self.memberLabel != nil,
|
||||
)
|
||||
}
|
||||
},
|
||||
@ -505,7 +504,7 @@ extension MemberActionSheet: ConversationHeaderDelegate {
|
||||
memberLabelCoordinator.presenter = presenter
|
||||
memberLabelCoordinator.presentWithEducationSheet(
|
||||
localUserHasMemberLabel: localUserHasMemberLabel,
|
||||
canEditMemberLabel: groupViewHelper.canEditConversationAttributes,
|
||||
canEditMemberLabel: groupViewHelper.canEditMemberLabels,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@ -2452,9 +2452,6 @@
|
||||
/* Label for 'revoke group admin' button in conversation settings view. */
|
||||
"CONVERSATION_SETTINGS_REVOKE_GROUP_ADMIN_BUTTON" = "Remove as Admin";
|
||||
|
||||
/* Message for 'revoke group admin' confirmation alert. */
|
||||
"CONVERSATION_SETTINGS_REVOKE_GROUP_ADMIN_MESSAGE" = "This will also clear their member label.";
|
||||
|
||||
/* Format for title for 'revoke group admin' confirmation alert. Embeds {user to revoke admin status from}. */
|
||||
"CONVERSATION_SETTINGS_REVOKE_GROUP_ADMIN_TITLE_FORMAT" = "Remove %@ as group admin?";
|
||||
|
||||
@ -5095,9 +5092,6 @@
|
||||
/* Label that shows up under a local user's row in contacts prompting them to add a member label */
|
||||
"MEMBER_LABEL_ADD_CSVC" = "Add Member Label";
|
||||
|
||||
/* Toast indicating that only admins can set a member label. */
|
||||
"MEMBER_LABEL_ADMIN_ONLY_WARNING_TOAST" = "Only admins can set member labels in this group";
|
||||
|
||||
/* Accessibility prefix for member labels. */
|
||||
"MEMBER_LABEL_AX_PREFIX" = "Member label: ";
|
||||
|
||||
|
||||
@ -508,11 +508,6 @@ public class GroupManager: NSObject {
|
||||
) async throws {
|
||||
try await updateGroupV2(groupModel: groupModel, description: "Change member role") { groupChangeSet in
|
||||
groupChangeSet.changeRoleForMember(aci, role: role)
|
||||
if BuildFlags.MemberLabel.send {
|
||||
if role == .normal, groupModel.access.attributes == .administrator {
|
||||
groupChangeSet.changeLabelForMember(aci, label: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -521,12 +516,6 @@ public class GroupManager: NSObject {
|
||||
public static func changeGroupAttributesAccessV2(groupModel: TSGroupModelV2, access: GroupV2Access) async throws {
|
||||
try await updateGroupV2(groupModel: groupModel, description: "Change group attributes access") { groupChangeSet in
|
||||
groupChangeSet.setAccessForAttributes(access)
|
||||
if BuildFlags.MemberLabel.send {
|
||||
let acisToClear = acisToClearMemberLabelsFor(groupModel: groupModel, access: access)
|
||||
for aci in acisToClear {
|
||||
groupChangeSet.changeLabelForMember(aci, label: nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -244,9 +244,6 @@ public class GroupsV2IncomingChanges {
|
||||
}
|
||||
|
||||
for action in changeActionsProto.modifyMemberLabel {
|
||||
if !canEditAttributes {
|
||||
owsFailDebug("Cannot modify member label.")
|
||||
}
|
||||
guard let userId = action.userID else {
|
||||
throw OWSAssertionError("Missing userID.")
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user