|  |  | @ -242,43 +242,45 @@ const NSUInteger kOWSProfileManager_MaxAvatarDiameter = 640; | 
			
		
	
		
		
			
				
					
					|  |  |  |         // Other threads may modify this profile's properties |  |  |  |         // Other threads may modify this profile's properties | 
			
		
	
		
		
			
				
					
					|  |  |  |         OWSAssert([userProfile isEqual:userProfileCopy]); |  |  |  |         OWSAssert([userProfile isEqual:userProfileCopy]); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |   | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     // Make sure to save on the local db connection for consistency. |  |  |  |     dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { |  |  |  |         // Make sure to save on the local db connection for consistency. | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         [userProfileCopy saveWithTransaction:transaction]; |  |  |  |         [self.dbConnection readWriteWithBlock:^(YapDatabaseReadWriteTransaction *transaction) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     }]; |  |  |  |             [userProfileCopy saveWithTransaction:transaction]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |         }]; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     BOOL isLocalUserProfile = userProfile == self.localUserProfile; |  |  |  |          | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |         BOOL isLocalUserProfile = userProfile == self.localUserProfile; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     dispatch_async(dispatch_get_main_queue(), ^{ |  |  |  |          | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |         if (isLocalUserProfile) { |  |  |  |         dispatch_async(dispatch_get_main_queue(), ^{ | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             // We populate an initial (empty) profile on launch of a new install, but until |  |  |  |             if (isLocalUserProfile) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             // we have a registered account, syncing will fail (and there could not be any |  |  |  |                 // We populate an initial (empty) profile on launch of a new install, but until | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             // linked device to sync to at this point anyway). |  |  |  |                 // we have a registered account, syncing will fail (and there could not be any | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             if ([TSAccountManager isRegistered]) { |  |  |  |                 // linked device to sync to at this point anyway). | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 [MultiDeviceProfileKeyUpdateJob runWithProfileKey:userProfile.profileKey |  |  |  |                 if ([TSAccountManager isRegistered]) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                                   identityManager:self.identityManager |  |  |  |                     [MultiDeviceProfileKeyUpdateJob runWithProfileKey:userProfile.profileKey | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                                     messageSender:self.messageSender |  |  |  |                                                       identityManager:self.identityManager | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                                                    profileManager:self]; |  |  |  |                                                         messageSender:self.messageSender | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                                        profileManager:self]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                  | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 [[NSNotificationCenter defaultCenter] postNotificationNameAsync:kNSNotificationName_LocalProfileDidChange | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                                                          object:nil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                                                                        userInfo:nil]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             } else { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 [[NSNotificationCenter defaultCenter] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                  postNotificationNameAsync:kNSNotificationName_OtherUsersProfileWillChange | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                  object:nil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                  userInfo:@{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             kNSNotificationKey_ProfileRecipientId : userProfile.recipientId, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 [[NSNotificationCenter defaultCenter] | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                  postNotificationNameAsync:kNSNotificationName_OtherUsersProfileDidChange | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                  object:nil | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                  userInfo:@{ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             kNSNotificationKey_ProfileRecipientId : userProfile.recipientId, | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                             }]; | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |         }); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |             [[NSNotificationCenter defaultCenter] postNotificationNameAsync:kNSNotificationName_LocalProfileDidChange |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                                                      object:nil |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                                                    userInfo:nil]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } else { |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             [[NSNotificationCenter defaultCenter] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 postNotificationNameAsync:kNSNotificationName_OtherUsersProfileWillChange |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                    object:nil |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                  userInfo:@{ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                      kNSNotificationKey_ProfileRecipientId : userProfile.recipientId, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                  }]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |             [[NSNotificationCenter defaultCenter] |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                 postNotificationNameAsync:kNSNotificationName_OtherUsersProfileDidChange |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                    object:nil |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                  userInfo:@{ |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                      kNSNotificationKey_ProfileRecipientId : userProfile.recipientId, |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |                                  }]; |  |  |  |  | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |  | 
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |     }); |  |  |  |     }); | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |