From afc68b25adb6606ffb70dcad90cb347fa4816bb7 Mon Sep 17 00:00:00 2001 From: Ivan Sein Date: Fri, 18 Dec 2020 15:07:29 +0100 Subject: [PATCH] Check "phonebook-search" capability. Signed-off-by: Ivan Sein --- NextcloudTalk/NCSettingsController.h | 1 + NextcloudTalk/NCSettingsController.m | 1 + NextcloudTalk/NewRoomTableViewController.m | 9 ++++++--- NextcloudTalk/SettingsViewController.m | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/NextcloudTalk/NCSettingsController.h b/NextcloudTalk/NCSettingsController.h index 46123ff7..bc467360 100644 --- a/NextcloudTalk/NCSettingsController.h +++ b/NextcloudTalk/NCSettingsController.h @@ -53,6 +53,7 @@ extern NSString * const kCapabilityChatReadMarker; extern NSString * const kCapabilityStartCallFlag; extern NSString * const kCapabilityCirclesSupport; extern NSString * const kCapabilityChatReferenceId; +extern NSString * const kCapabilityPhonebookSearch; extern NSInteger const kDefaultChatMaxLength; extern NSString * const kMinimumRequiredTalkCapability; diff --git a/NextcloudTalk/NCSettingsController.m b/NextcloudTalk/NCSettingsController.m index 33eae549..27ede243 100644 --- a/NextcloudTalk/NCSettingsController.m +++ b/NextcloudTalk/NCSettingsController.m @@ -77,6 +77,7 @@ NSString * const kCapabilityChatReadMarker = @"chat-read-marker"; NSString * const kCapabilityStartCallFlag = @"start-call-flag"; NSString * const kCapabilityCirclesSupport = @"circles-support"; NSString * const kCapabilityChatReferenceId = @"chat-reference-id"; +NSString * const kCapabilityPhonebookSearch = @"phonebook-search"; NSInteger const kDefaultChatMaxLength = 1000; NSString * const kMinimumRequiredTalkCapability = kCapabilitySystemMessages; // Talk 4.0 is the minimum required version diff --git a/NextcloudTalk/NewRoomTableViewController.m b/NextcloudTalk/NewRoomTableViewController.m index 7dd726ba..b5158210 100644 --- a/NextcloudTalk/NewRoomTableViewController.m +++ b/NextcloudTalk/NewRoomTableViewController.m @@ -160,7 +160,7 @@ NSString * const NCSelectedContactForChatNotification = @"NCSelectedContactForCh self.navigationController.navigationBar.topItem.leftBarButtonItem = cancelButton; self.navigationController.navigationBar.topItem.leftBarButtonItem.accessibilityHint = NSLocalizedString(@"Cancel conversation creation", nil); - if ([[NCSettingsController sharedInstance] isContactSyncEnabled]) { + if ([[NCSettingsController sharedInstance] isContactSyncEnabled] && [[NCSettingsController sharedInstance] serverHasTalkCapability:kCapabilityPhonebookSearch]) { UIBarButtonItem *moreOptionButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"more-action"] style:UIBarButtonItemStylePlain target:self @@ -189,8 +189,11 @@ NSString * const NCSelectedContactForChatNotification = @"NCSelectedContactForCh self.navigationItem.hidesSearchBarWhenScrolling = NO; } - [[NCContactsManager sharedInstance] searchInServerForAddressBookContacts:NO]; - [self getAddressBookContacts]; + if ([[NCSettingsController sharedInstance] isContactSyncEnabled] && [[NCSettingsController sharedInstance] serverHasTalkCapability:kCapabilityPhonebookSearch]) { + [[NCContactsManager sharedInstance] searchInServerForAddressBookContacts:NO]; + [self getAddressBookContacts]; + } + [self getServerContacts]; } diff --git a/NextcloudTalk/SettingsViewController.m b/NextcloudTalk/SettingsViewController.m index e4ca6db9..0b14927c 100644 --- a/NextcloudTalk/SettingsViewController.m +++ b/NextcloudTalk/SettingsViewController.m @@ -180,7 +180,9 @@ typedef enum AboutSection { [options addObject:[NSNumber numberWithInt:kConfigurationSectionOptionBrowser]]; } // Contacts sync - [options addObject:[NSNumber numberWithInt:kConfigurationSectionOptionContactsSync]]; + if ([[NCSettingsController sharedInstance] serverHasTalkCapability:kCapabilityPhonebookSearch]) { + [options addObject:[NSNumber numberWithInt:kConfigurationSectionOptionContactsSync]]; + } return [NSArray arrayWithArray:options]; }