Minor refactoring

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

@ -531,28 +531,23 @@ 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
if (![self.thread.contactIdentifier isEqualToString:hexEncodedPublicKey]) {
[OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) { [OWSPrimaryStorage.sharedManager.dbReadConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
NSSet<NSString *> *linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:self.thread.contactIdentifier in:transaction]; NSSet<NSString *> *linkedDevices = [LKDatabaseUtilities getLinkedDeviceHexEncodedPublicKeysFor:self.thread.contactIdentifier in:transaction];
shouldReload = [linkedDevices containsObject:hexEncodedPublicKey]; needsUpdate = [linkedDevices containsObject:hexEncodedPublicKey];
}]; }];
} if (!needsUpdate) { return; }
if (shouldReload) { // Ensure the thread instance is up to date
// Ensure thread instance is up to date
[self.thread reload]; [self.thread reload];
// Update UI // Update the UI
[self.viewItems.lastObject clearCachedLayoutState]; [self.viewItems.lastObject clearCachedLayoutState];
[self updateInputToolbar]; [self updateInputToolbar];
[self resetContentAndLayout]; [self resetContentAndLayout];
} }
}
- (void)handleThreadSessionRestoreDevicesChangedNotifiaction:(NSNotification *)notification - (void)handleThreadSessionRestoreDevicesChangedNotifiaction:(NSNotification *)notification
{ {

Loading…
Cancel
Save