Minor refactoring

pull/175/head
nielsandriesse 5 years ago
parent 488f821881
commit fce6fe1170

@ -531,27 +531,22 @@ typedef enum : NSUInteger {
- (void)handleUserFriendRequestStatusChangedNotification:(NSNotification *)notification - (void)handleUserFriendRequestStatusChangedNotification:(NSNotification *)notification
{ {
// Check thread // Friend request status doesn't apply to group threads
NSString *hexEncodedPublicKey = (NSString *)notification.object;
if (self.thread.isGroupThread) { return; } if (self.thread.isGroupThread) { return; }
NSString *hexEncodedPublicKey = (NSString *)notification.object;
__block BOOL shouldReload = [self.thread.contactIdentifier isEqualToString:hexEncodedPublicKey]; // Check if we should update the UI
__block BOOL needsUpdate;
// Check to see if this is a linked device [OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
if (![self.thread.contactIdentifier isEqualToString:hexEncodedPublicKey]) { NSSet<NSString *> *linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:self.thread.contactIdentifier in:transaction];
[OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { needsUpdate = [linkedDevices containsObject:hexEncodedPublicKey];
NSSet<NSString *> *linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:self.thread.contactIdentifier in:transaction]; }];
shouldReload = [linkedDevices containsObject:hexEncodedPublicKey]; if (!needsUpdate) { return; }
}]; // Ensure the thread instance is up to date
} [self.thread reload];
if (shouldReload) { // Update the UI
// Ensure thread instance is up to date [self.viewItems.lastObject clearCachedLayoutState];
[self.thread reload]; [self updateInputToolbar];
// Update UI [self resetContentAndLayout];
[self.viewItems.lastObject clearCachedLayoutState];
[self updateInputToolbar];
[self resetContentAndLayout];
}
} }
- (void)handleThreadSessionRestoreDevicesChangedNotifiaction:(NSNotification *)notification - (void)handleThreadSessionRestoreDevicesChangedNotifiaction:(NSNotification *)notification

Loading…
Cancel
Save