From 83b37257712eeae76e8c03edad4c3602f4148bd9 Mon Sep 17 00:00:00 2001 From: Paul Cartier Date: Thu, 30 Apr 2020 14:54:33 +0200 Subject: [PATCH] Wait for phone contact to be loaded before wrinting to userdefaults --- Classes/Utils/FastAddressBook.m | 42 ++++++++++++++++----------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 25958cc8f..408784976 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -203,30 +203,30 @@ }]; } - }]; - // load Linphone friends - const MSList *lists = linphone_core_get_friends_lists(LC); - while (lists) { - LinphoneFriendList *fl = lists->data; - const MSList *friends = linphone_friend_list_get_friends(fl); - while (friends) { - LinphoneFriend *f = friends->data; - // only append friends that are not native contacts (already added - // above) - if (linphone_friend_get_ref_key(f) == NULL) { - Contact *contact = [[Contact alloc] initWithFriend:f]; - [self registerAddrsFor:contact]; + // load Linphone friends + const MSList *lists = linphone_core_get_friends_lists(LC); + while (lists) { + LinphoneFriendList *fl = lists->data; + const MSList *friends = linphone_friend_list_get_friends(fl); + while (friends) { + LinphoneFriend *f = friends->data; + // only append friends that are not native contacts (already added + // above) + if (linphone_friend_get_ref_key(f) == NULL) { + Contact *contact = [[Contact alloc] initWithFriend:f]; + [self registerAddrsFor:contact]; + } + friends = friends->next; } - friends = friends->next; + linphone_friend_list_update_subscriptions(fl); + lists = lists->next; } - linphone_friend_list_update_subscriptions(fl); - lists = lists->next; - } - [self dumpContactsDisplayNamesToUserDefaults]; + [self dumpContactsDisplayNamesToUserDefaults]; - [NSNotificationCenter.defaultCenter - postNotificationName:kLinphoneAddressBookUpdate - object:self]; + [NSNotificationCenter.defaultCenter + postNotificationName:kLinphoneAddressBookUpdate + object:self]; + }]; } -(void) updateAddressBook:(NSNotification*) notif {