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

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

@ -232,6 +232,17 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
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
{
[self.dbReadWriteConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *_Nonnull transaction) {
@ -252,7 +263,7 @@ NSString *const TSGroupThread_NotificationKey_UniqueId = @"TSGroupThread_Notific
[transaction addCompletionQueue:dispatch_get_main_queue()
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
public static let contactOnlineStatusChanged = Notification.Name("contactOnlineStatusChanged")
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 threadDeleted = Notification.Name("threadDeleted")
public static let threadSessionRestoreDevicesChanged = Notification.Name("threadSessionRestoreDevicesChanged")
@ -27,7 +27,7 @@ public extension Notification.Name {
// State changes
@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 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 threadDeleted = Notification.Name.threadDeleted.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;
NSString *updateGroupInfo = [newGroupThread.groupModel getInfoStringAboutUpdateTo:newGroupModel
contactsManager:self.contactsManager];
newGroupThread.groupModel = newGroupModel;
[newGroupThread saveWithTransaction:transaction];
// Loki: Try to establish sessions with all members when a group is created or updated
[self establishSessionsWithMembersIfNeeded: newMemberIds.allObjects forThread:newGroupThread transaction:transaction];
[newGroupThread updateGroupModel:newGroupModel withTransaction: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
thread:newGroupThread
@ -1518,7 +1521,7 @@ NS_ASSUME_NONNULL_BEGIN
[infoMessage saveWithTransaction:transaction];
// If we were the one that was removed then we need to leave the group
if ([removedMemberIds containsObject:ourHexEncodedPublicKey]) {
if (removedFromGroup) {
[newGroupThread leaveGroupWithTransaction:transaction];
}

Loading…
Cancel
Save