This commit is contained in:
nielsandriesse 2020-09-29 14:36:18 +10:00
parent 050d171f5c
commit 1a78ba1830
4 changed files with 35 additions and 26 deletions

View File

@ -5,7 +5,7 @@ enum ContactUtilities {
var result: [String] = []
Storage.read { transaction 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())
}
}

View File

@ -227,18 +227,24 @@ final class EditClosedGroupVC : BaseVC, UITableViewDataSource, UITableViewDelega
}
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 groupPublicKey = LKGroupUtilities.getDecodedGroupID(groupID)
let members = Set(self.members)
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
ClosedGroupsProtocol.update(groupPublicKey, with: members, name: name, transaction: transaction).done(on: DispatchQueue.main) {
guard let self = self else { return }
if let conversationVC = self.navigationController!.viewControllers.first(where: { $0 is ConversationViewController }) {
self.navigationController!.popToViewController(conversationVC, animated: true)
} else {
self.navigationController!.popViewController(animated: true)
}
popToConversationVC(self)
}.catch(on: DispatchQueue.main) { error in
guard let self = self else { return }
self.showError(title: "Couldn't Update Group", message: "Please check your internet connection and try again.")

View File

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

View File

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