This commit is contained in:
Niels Andriesse 2021-01-11 09:55:20 +11:00
parent f5786a11fe
commit 4156b0e87e
3 changed files with 14 additions and 6 deletions

View File

@ -896,9 +896,17 @@ static CGRect oldframe;
- (void)didTapLeaveGroup
{
NSString *userPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
NSString *message;
if ([((TSGroupThread *)self.thread).groupModel.groupAdminIds containsObject:userPublicKey]) {
message = @"Because you are the creator of this group it will be deleted for everyone. This cannot be undone.";
} else {
message = NSLocalizedString(@"CONFIRM_LEAVE_GROUP_DESCRIPTION", @"Alert body");
}
UIAlertController *alert =
[UIAlertController alertControllerWithTitle:NSLocalizedString(@"CONFIRM_LEAVE_GROUP_TITLE", @"Alert title")
message:NSLocalizedString(@"CONFIRM_LEAVE_GROUP_DESCRIPTION", @"Alert body")
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *leaveAction = [UIAlertAction

View File

@ -253,7 +253,7 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
return popToConversationVC(self)
}
if !members.contains(getUserHexEncodedPublicKey()) {
guard members.intersection(Set(thread.groupModel.groupMemberIds).subtracting([ getUserHexEncodedPublicKey() ])) == members else {
guard Set(thread.groupModel.groupMemberIds).subtracting([ getUserHexEncodedPublicKey() ]) == members else {
return showError(title: "Couldn't Update Group", message: "Can't leave while adding or removing other members.")
}
}

View File

@ -426,13 +426,13 @@ final class HomeVC : BaseVC, UITableViewDataSource, UITableViewDelegate, UIScrol
let groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID)
do {
try MessageSender.leaveV2(groupPublicKey, using: transaction)
Storage.write { transaction in
thread.removeAllThreadInteractions(with: transaction)
thread.remove(with: transaction)
}
} catch {
// TODO: Handle
}
Storage.write { transaction in
thread.removeAllThreadInteractions(with: transaction)
thread.remove(with: transaction)
}
} else {
thread.removeAllThreadInteractions(with: transaction)
thread.remove(with: transaction)