diff --git a/src/Contacts/ContactsUpdater.h b/src/Contacts/ContactsUpdater.h index bfd6dcdab..2b806cd00 100644 --- a/src/Contacts/ContactsUpdater.h +++ b/src/Contacts/ContactsUpdater.h @@ -1,5 +1,6 @@ -// Created by Frederic Jacobs on 21/11/15. -// Copyright © 2015 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "SignalRecipient.h" @@ -15,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN - (nullable SignalRecipient *)synchronousLookup:(NSString *)identifier error:(NSError **)error; +// This asynchronously updates the SignalRecipient for a given contactId. - (void)lookupIdentifier:(NSString *)identifier success:(void (^)(NSSet *matchedIds))success failure:(void (^)(NSError *error))failure; diff --git a/src/Contacts/Threads/TSContactThread.m b/src/Contacts/Threads/TSContactThread.m index 39be4e5d1..4958986d3 100644 --- a/src/Contacts/Threads/TSContactThread.m +++ b/src/Contacts/Threads/TSContactThread.m @@ -1,5 +1,6 @@ -// Created by Frederic Jacobs on 16/11/14. -// Copyright (c) 2014 Open Whisper Systems. All rights reserved. +// +// Copyright (c) 2017 Open Whisper Systems. All rights reserved. +// #import "TSContactThread.h" #import "ContactsManagerProtocol.h" @@ -32,12 +33,15 @@ NS_ASSUME_NONNULL_BEGIN [SignalRecipient recipientWithTextSecureIdentifier:contactId withTransaction:transaction]; if (!recipient) { + // If no recipient record exists for that contactId, create an empty record + // for immediate use, then ask ContactsUpdater to try to update it async. recipient = [[SignalRecipient alloc] initWithTextSecureIdentifier:contactId relay:relay supportsVoice:YES // Default to NO; ContactsUpdater will try to update this property. supportsWebRTC:NO]; + [recipient saveWithTransaction:transaction]; [[ContactsUpdater sharedUpdater] lookupIdentifier:contactId success:^(NSSet *matchedIds) { @@ -45,7 +49,6 @@ NS_ASSUME_NONNULL_BEGIN failure:^(NSError *error) { DDLogWarn(@"Failed to lookup contact with error:%@", error); }]; - [recipient saveWithTransaction:transaction]; } return [self getOrCreateThreadWithContactId:contactId transaction:transaction];