From fce6fe1170e26e6ced9cc182ffe22a7bdefaab83 Mon Sep 17 00:00:00 2001 From: nielsandriesse Date: Sat, 2 May 2020 09:10:36 +1000 Subject: [PATCH] Minor refactoring --- .../ConversationViewController.m | 35 ++++++++----------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m index df59c216a..69d193b74 100644 --- a/Signal/src/ViewControllers/ConversationView/ConversationViewController.m +++ b/Signal/src/ViewControllers/ConversationView/ConversationViewController.m @@ -531,27 +531,22 @@ typedef enum : NSUInteger { - (void)handleUserFriendRequestStatusChangedNotification:(NSNotification *)notification { - // Check thread - NSString *hexEncodedPublicKey = (NSString *)notification.object; + // Friend request status doesn't apply to group threads if (self.thread.isGroupThread) { return; } - - __block BOOL shouldReload = [self.thread.contactIdentifier isEqualToString:hexEncodedPublicKey]; - - // Check to see if this is a linked device - if (![self.thread.contactIdentifier isEqualToString:hexEncodedPublicKey]) { - [OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { - NSSet *linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:self.thread.contactIdentifier in:transaction]; - shouldReload = [linkedDevices containsObject:hexEncodedPublicKey]; - }]; - } - if (shouldReload) { - // Ensure thread instance is up to date - [self.thread reload]; - // Update UI - [self.viewItems.lastObject clearCachedLayoutState]; - [self updateInputToolbar]; - [self resetContentAndLayout]; - } + NSString *hexEncodedPublicKey = (NSString *)notification.object; + // Check if we should update the UI + __block BOOL needsUpdate; + [OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { + NSSet *linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:self.thread.contactIdentifier in:transaction]; + needsUpdate = [linkedDevices containsObject:hexEncodedPublicKey]; + }]; + if (!needsUpdate) { return; } + // Ensure the thread instance is up to date + [self.thread reload]; + // Update the UI + [self.viewItems.lastObject clearCachedLayoutState]; + [self updateInputToolbar]; + [self resetContentAndLayout]; } - (void)handleThreadSessionRestoreDevicesChangedNotifiaction:(NSNotification *)notification