pull/280/head
nielsandriesse 4 years ago
parent 050d171f5c
commit 1a78ba1830

@ -5,7 +5,7 @@ enum ContactUtilities {
var result: [String] = [] var result: [String] = []
Storage.read { transaction in Storage.read { transaction in
TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in TSContactThread.enumerateCollectionObjects(with: transaction) { object, _ in
guard let thread = object as? TSContactThread else { return } guard let thread = object as? TSContactThread, thread.shouldThreadBeVisible else { return }
result.append(thread.contactIdentifier()) result.append(thread.contactIdentifier())
} }
} }

@ -227,18 +227,24 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
} }
private func commitChanges() { private func commitChanges() {
let popToConversationVC: (EditClosedGroupVC) -> Void = { editVC in
if let conversationVC = editVC.navigationController!.viewControllers.first(where: { $0 is ConversationViewController }) {
editVC.navigationController!.popToViewController(conversationVC, animated: true)
} else {
editVC.navigationController!.popViewController(animated: true)
}
}
let groupID = thread.groupModel.groupId let groupID = thread.groupModel.groupId
let groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID) let groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID)
let members = Set(self.members) let members = Set(self.members)
let name = self.name let name = self.name
guard members != Set(thread.groupModel.groupMemberIds) || name != thread.groupModel.groupName else {
return popToConversationVC(self)
}
try! Storage.writeSync { [weak self] transaction in try! Storage.writeSync { [weak self] transaction in
ClosedGroupsProtocol.update(groupPublicKey, with: members, name: name, transaction: transaction).done(on: DispatchQueue.main) { ClosedGroupsProtocol.update(groupPublicKey, with: members, name: name, transaction: transaction).done(on: DispatchQueue.main) {
guard let self = self else { return } guard let self = self else { return }
if let conversationVC = self.navigationController!.viewControllers.first(where: { $0 is ConversationViewController }) { popToConversationVC(self)
self.navigationController!.popToViewController(conversationVC, animated: true)
} else {
self.navigationController!.popViewController(animated: true)
}
}.catch(on: DispatchQueue.main) { error in }.catch(on: DispatchQueue.main) { error in
guard let self = self else { return } guard let self = self else { return }
self.showError(title: "Couldn't Update Group", message: "Please check your internet connection and try again.") self.showError(title: "Couldn't Update Group", message: "Please check your internet connection and try again.")

@ -649,8 +649,13 @@ const CGFloat kIconViewLength = 24;
// Group settings section. // Group settings section.
__block BOOL isUserMember;
if (self.isGroupThread && self.isPrivateGroupChat) { NSString *userPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey;
[LKStorage readWithBlock:^(YapDatabaseReadTransaction *transaction) {
isUserMember = [(TSGroupThread *)self.thread isUserMemberInGroup:userPublicKey transaction:transaction];
}];
if (self.isGroupThread && self.isPrivateGroupChat && isUserMember) {
if (((TSGroupThread *)self.thread).usesSharedSenderKeys) { if (((TSGroupThread *)self.thread).usesSharedSenderKeys) {
[mainSection addItem:[OWSTableItem [mainSection addItem:[OWSTableItem
itemWithCustomCellBlock:^{ itemWithCustomCellBlock:^{
@ -682,25 +687,22 @@ const CGFloat kIconViewLength = 24;
// [weakSelf showGroupMembersView]; // [weakSelf showGroupMembersView];
// }] // }]
// ]; // ];
NSString *userPublicKey = OWSIdentityManager.sharedManager.identityKeyPair.hexEncodedPublicKey; [mainSection addItem:[OWSTableItem
if ([((TSGroupThread *)self.thread).groupModel.groupMemberIds containsObject:userPublicKey]) { itemWithCustomCellBlock:^{
[mainSection addItem:[OWSTableItem UITableViewCell *cell =
itemWithCustomCellBlock:^{ [weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION",
UITableViewCell *cell = @"table cell label in conversation settings")
[weakSelf disclosureCellWithName:NSLocalizedString(@"LEAVE_GROUP_ACTION", iconName:@"table_ic_group_leave"
@"table cell label in conversation settings") accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME(
iconName:@"table_ic_group_leave" OWSConversationSettingsViewController, @"leave_group")];
accessibilityIdentifier:ACCESSIBILITY_IDENTIFIER_WITH_NAME( cell.userInteractionEnabled = !weakSelf.hasLeftGroup;
OWSConversationSettingsViewController, @"leave_group")];
cell.userInteractionEnabled = !weakSelf.hasLeftGroup; return cell;
}
return cell; actionBlock:^{
} [weakSelf didTapLeaveGroup];
actionBlock:^{ }]
[weakSelf didTapLeaveGroup]; ];
}]
];
}
} }

@ -151,6 +151,7 @@ public final class ClosedGroupsProtocol : NSObject {
} }
} }
} else { } else {
seal.fulfill(())
// Generate ratchets for any new members // Generate ratchets for any new members
newSenderKeys = newMembers.map { publicKey in newSenderKeys = newMembers.map { publicKey in
let ratchet = SharedSenderKeysImplementation.shared.generateRatchet(for: groupPublicKey, senderPublicKey: publicKey, using: transaction) let ratchet = SharedSenderKeysImplementation.shared.generateRatchet(for: groupPublicKey, senderPublicKey: publicKey, using: transaction)

Loading…
Cancel
Save