From c07d7777cb1de394cb40f7ac7838c652a626d34a Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 14 Dec 2017 13:18:51 -0500 Subject: [PATCH 1/3] Reinstate notification when SignalAccounts change // FREEBIE --- Signal/src/ViewControllers/DebugUI/DebugUIContacts.m | 10 ++++++++++ Signal/src/contact/OWSContactsManager.m | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m b/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m index 24a5990a3..34ea4e2eb 100644 --- a/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m +++ b/Signal/src/ViewControllers/DebugUI/DebugUIContacts.m @@ -46,6 +46,10 @@ NS_ASSUME_NONNULL_BEGIN actionBlock:^{ [DebugUIContacts deleteAllContacts]; }], + [OWSTableItem itemWithTitle:@"Clear SignalAccount Cache" + actionBlock:^{ + [DebugUIContacts clearSignalAccountCache]; + }], ]]; } @@ -1280,6 +1284,12 @@ NS_ASSUME_NONNULL_BEGIN }]; } ++ (void)clearSignalAccountCache +{ + DDLogWarn(@"%@ Deleting all signal accounts.", self.logTag); + [SignalAccount removeAllObjectsInCollection]; +} + + (void)deleteAllContacts { [self deleteContactsWithFilter:^(CNContact *contact) { diff --git a/Signal/src/contact/OWSContactsManager.m b/Signal/src/contact/OWSContactsManager.m index a283d354a..49cdc9230 100644 --- a/Signal/src/contact/OWSContactsManager.m +++ b/Signal/src/contact/OWSContactsManager.m @@ -273,6 +273,10 @@ NSString *const OWSContactsManagerSignalAccountsDidChangeNotification self.signalAccountMap = [signalAccountMap copy]; self.signalAccounts = [signalAccounts copy]; [self.profileManager setContactRecipientIds:signalAccountMap.allKeys]; + + [[NSNotificationCenter defaultCenter] + postNotificationNameAsync:OWSContactsManagerSignalAccountsDidChangeNotification + object:nil]; } // TODO dependency inject, avoid circular dependencies. From 1f8042685d21ac750d2611c7a6a7e0d8b9d41fa1 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 14 Dec 2017 13:45:54 -0500 Subject: [PATCH 2/3] Show loading cell when contacts are still loading. // FREEBIE --- .../NewContactThreadViewController.m | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/Signal/src/ViewControllers/NewContactThreadViewController.m b/Signal/src/ViewControllers/NewContactThreadViewController.m index 9b65ec0a6..8f0f759c0 100644 --- a/Signal/src/ViewControllers/NewContactThreadViewController.m +++ b/Signal/src/ViewControllers/NewContactThreadViewController.m @@ -396,14 +396,34 @@ NS_ASSUME_NONNULL_BEGIN // No Contacts OWSTableSection *contactsSection = [OWSTableSection new]; - if (self.contactsViewHelper.contactsManager.isSystemContactsAuthorized - && self.contactsViewHelper.hasUpdatedContactsAtLeastOnce) { - - [contactsSection - addItem:[OWSTableItem - softCenterLabelItemWithText:NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_CONTACTS", - @"A label that indicates the user has no Signal contacts.") - customRowHeight:self.actionCellHeight]]; + if (self.contactsViewHelper.contactsManager.isSystemContactsAuthorized) { + if (self.contactsViewHelper.hasUpdatedContactsAtLeastOnce) { + + [contactsSection + addItem:[OWSTableItem softCenterLabelItemWithText: + NSLocalizedString(@"SETTINGS_BLOCK_LIST_NO_CONTACTS", + @"A label that indicates the user has no Signal contacts.") + customRowHeight:self.actionCellHeight]]; + } else { + UITableViewCell *loadingCell = [UITableViewCell new]; + OWSAssert(loadingCell.contentView); + + UIActivityIndicatorView *activityIndicatorView = + [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; + [loadingCell.contentView addSubview:activityIndicatorView]; + [activityIndicatorView startAnimating]; + + [activityIndicatorView autoCenterInSuperview]; + [activityIndicatorView setCompressionResistanceHigh]; + [activityIndicatorView setContentHuggingHigh]; + + // hide separator for loading cell. The loading cell doesn't really feel like a cell + loadingCell.backgroundView = [UIView new]; + + OWSTableItem *loadingItem = + [OWSTableItem itemWithCustomCell:loadingCell customRowHeight:40 actionBlock:nil]; + [contactsSection addItem:loadingItem]; + } } return @[ contactsSection ]; From f182450090ec6e3992c315eb331506f3061cac29 Mon Sep 17 00:00:00 2001 From: Michael Kirk Date: Thu, 14 Dec 2017 13:53:40 -0500 Subject: [PATCH 3/3] bump build // FREEBIE --- Signal/Signal-Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Signal/Signal-Info.plist b/Signal/Signal-Info.plist index 4cfb71736..42f777198 100644 --- a/Signal/Signal-Info.plist +++ b/Signal/Signal-Info.plist @@ -55,7 +55,7 @@ CFBundleVersion - 2.19.3.0 + 2.19.3.1 ITSAppUsesNonExemptEncryption LOGS_EMAIL