Fix iOS input being hidden after being removed then added to a group.

pull/154/head
Mikunj 5 years ago
parent 1e1459d6d2
commit 7243dcb48d

@ -425,8 +425,8 @@ typedef enum : NSUInteger {
name:NSNotification.threadSessionRestoreDevicesChanged name:NSNotification.threadSessionRestoreDevicesChanged
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleGroupThreadLeftNotification:) selector:@selector(handleGroupThreadUpdated:)
name:NSNotification.groupThreadLeft name:NSNotification.groupThreadUpdated
object:nil]; object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self [[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(handleCalculatingPoWNotification:) selector:@selector(handleCalculatingPoWNotification:)
@ -511,7 +511,7 @@ typedef enum : NSUInteger {
[self ensureBannerState]; [self ensureBannerState];
} }
- (void)handleGroupThreadLeftNotification:(NSNotification *)notification - (void)handleGroupThreadUpdated:(NSNotification *)notification
{ {
OWSAssertIsOnMainThread(); OWSAssertIsOnMainThread();

@ -45,6 +45,7 @@ extern NSString *const TSGroupThread_NotificationKey_UniqueId;
+ (NSArray<TSGroupThread *> *)groupThreadsWithRecipientId:(NSString *)recipientId + (NSArray<TSGroupThread *> *)groupThreadsWithRecipientId:(NSString *)recipientId
transaction:(YapDatabaseReadWriteTransaction *)transaction; transaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)updateGroupModel:(TSGroupModel *)newGroupModel withTransaction:(YapDatabaseReadWriteTransaction *)transaction;
- (void)leaveGroupWithSneakyTransaction; - (void)leaveGroupWithSneakyTransaction;
- (void)leaveGroupWithTransaction:(YapDatabaseReadWriteTransaction *)transaction; - (void)leaveGroupWithTransaction:(YapDatabaseReadWriteTransaction *)transaction;

@ -232,6 +232,17 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
return NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @""); return NSLocalizedString(@"NEW_GROUP_DEFAULT_TITLE", @"");
} }
- (void)updateGroupModel:(TSGroupModel *)newGroupModel withTransaction:(YapDatabaseReadWriteTransaction *)transaction
{
self.groupModel = newGroupModel;
[self saveWithTransaction:transaction];
[transaction addCompletionQueue:dispatch_get_main_queue()
completionBlock:^{
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.groupThreadUpdated object:self.uniqueId];
}];
}
- (void)leaveGroupWithSneakyTransaction - (void)leaveGroupWithSneakyTransaction
{ {
[self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) { [self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
@ -252,7 +263,7 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
[transaction addCompletionQueue:dispatch_get_main_queue() [transaction addCompletionQueue:dispatch_get_main_queue()
completionBlock:^{ completionBlock:^{
[NSNotificationCenter.defaultCenter postNotificationName:NSNotification.groupThreadLeft object:self.uniqueId]; [NSNotificationCenter.defaultCenter postNotificationName:NSNotification.groupThreadUpdated object:self.uniqueId];
}]; }];
} }

@ -4,7 +4,7 @@ public extension Notification.Name {
// State changes // State changes
public static let contactOnlineStatusChanged = Notification.Name("contactOnlineStatusChanged") public static let contactOnlineStatusChanged = Notification.Name("contactOnlineStatusChanged")
public static let threadFriendRequestStatusChanged = Notification.Name("threadFriendRequestStatusChanged") public static let threadFriendRequestStatusChanged = Notification.Name("threadFriendRequestStatusChanged")
public static let groupThreadLeft = Notification.Name("groupThreadLeft") public static let groupThreadUpdated = Notification.Name("groupThreadLeft")
public static let messageFriendRequestStatusChanged = Notification.Name("messageFriendRequestStatusChanged") public static let messageFriendRequestStatusChanged = Notification.Name("messageFriendRequestStatusChanged")
public static let threadDeleted = Notification.Name("threadDeleted") public static let threadDeleted = Notification.Name("threadDeleted")
public static let threadSessionRestoreDevicesChanged = Notification.Name("threadSessionRestoreDevicesChanged") public static let threadSessionRestoreDevicesChanged = Notification.Name("threadSessionRestoreDevicesChanged")
@ -27,7 +27,7 @@ public extension Notification.Name {
// State changes // State changes
@objc public static let contactOnlineStatusChanged = Notification.Name.contactOnlineStatusChanged.rawValue as NSString @objc public static let contactOnlineStatusChanged = Notification.Name.contactOnlineStatusChanged.rawValue as NSString
@objc public static let threadFriendRequestStatusChanged = Notification.Name.threadFriendRequestStatusChanged.rawValue as NSString @objc public static let threadFriendRequestStatusChanged = Notification.Name.threadFriendRequestStatusChanged.rawValue as NSString
@objc public static let groupThreadLeft = Notification.Name.groupThreadLeft.rawValue as NSString @objc public static let groupThreadUpdated = Notification.Name.groupThreadUpdated.rawValue as NSString
@objc public static let messageFriendRequestStatusChanged = Notification.Name.messageFriendRequestStatusChanged.rawValue as NSString @objc public static let messageFriendRequestStatusChanged = Notification.Name.messageFriendRequestStatusChanged.rawValue as NSString
@objc public static let threadDeleted = Notification.Name.threadDeleted.rawValue as NSString @objc public static let threadDeleted = Notification.Name.threadDeleted.rawValue as NSString
@objc public static let threadSessionRestoreDevicesChanged = Notification.Name.threadSessionRestoreDevicesChanged.rawValue as NSString @objc public static let threadSessionRestoreDevicesChanged = Notification.Name.threadSessionRestoreDevicesChanged.rawValue as NSString

@ -1498,11 +1498,14 @@ NS_ASSUME_NONNULL_BEGIN
newGroupModel.removedMembers = removedMemberIds; newGroupModel.removedMembers = removedMemberIds;
NSString *updateGroupInfo = [newGroupThread.groupModel getInfoStringAboutUpdateTo:newGroupModel NSString *updateGroupInfo = [newGroupThread.groupModel getInfoStringAboutUpdateTo:newGroupModel
contactsManager:self.contactsManager]; contactsManager:self.contactsManager];
newGroupThread.groupModel = newGroupModel;
[newGroupThread saveWithTransaction:transaction];
// Loki: Try to establish sessions with all members when a group is created or updated [newGroupThread updateGroupModel:newGroupModel withTransaction:transaction];
[self establishSessionsWithMembersIfNeeded: newMemberIds.allObjects forThread:newGroupThread transaction:transaction];
BOOL removedFromGroup = [removedMemberIds containsObject:ourHexEncodedPublicKey];
if (!removedFromGroup) {
// Loki: Try to establish sessions with all members when a group is created or updated
[self establishSessionsWithMembersIfNeeded: newMemberIds.allObjects forThread:newGroupThread transaction:transaction];
}
[[OWSDisappearingMessagesJob sharedJob] becomeConsistentWithDisappearingDuration:dataMessage.expireTimer [[OWSDisappearingMessagesJob sharedJob] becomeConsistentWithDisappearingDuration:dataMessage.expireTimer
thread:newGroupThread thread:newGroupThread
@ -1518,7 +1521,7 @@ NS_ASSUME_NONNULL_BEGIN
[infoMessage saveWithTransaction:transaction]; [infoMessage saveWithTransaction:transaction];
// If we were the one that was removed then we need to leave the group // If we were the one that was removed then we need to leave the group
if ([removedMemberIds containsObject:ourHexEncodedPublicKey]) { if (removedFromGroup) {
[newGroupThread leaveGroupWithTransaction:transaction]; [newGroupThread leaveGroupWithTransaction:transaction];
} }

Loading…
Cancel
Save