diff --git a/Signal/src/Loki/Utilities/ContactUtilities.swift b/Signal/src/Loki/Utilities/ContactUtilities.swift index 47aefde46..804d5f9c9 100644 --- a/Signal/src/Loki/Utilities/ContactUtilities.swift +++ b/Signal/src/Loki/Utilities/ContactUtilities.swift @@ -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()) } } diff --git a/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift b/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift index 86627dbf4..02548f496 100644 --- a/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift +++ b/Signal/src/Loki/View Controllers/EditClosedGroupVC.swift @@ -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.") diff --git a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m index efc9931d7..094e1d325 100644 --- a/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m +++ b/Signal/src/ViewControllers/ThreadSettings/OWSConversationSettingsViewController.m @@ -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; - - return cell; - } - actionBlock:^{ - [weakSelf didTapLeaveGroup]; - }] - ]; - } + [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]; + }] + ]; } diff --git a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift index c9eb2e1b2..d04d75eaf 100644 --- a/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift +++ b/SignalServiceKit/src/Loki/Protocol/Closed Groups/ClosedGroupsProtocol.swift @@ -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)