From a5526415fbe53f4c3a170dc171395ee41a7e07d2 Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Thu, 1 Apr 2021 15:02:43 +0200 Subject: [PATCH 1/2] Enable / disable external friends invite --- Config/BuildSettings.swift | 2 ++ Riot/Managers/Settings/RiotSettings.swift | 15 +++++++++++++++ .../Contacts/DataSources/ContactsDataSource.m | 2 +- Riot/Modules/StartChat/StartChatViewController.m | 6 ++++++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/Config/BuildSettings.swift b/Config/BuildSettings.swift index 5612061e0..ef6fc2a87 100644 --- a/Config/BuildSettings.swift +++ b/Config/BuildSettings.swift @@ -195,6 +195,8 @@ final class BuildSettings: NSObject { static let allowLocalContactsAccess: Bool = true + static let allowInviteExernalUsers: Bool = true + // MARK: - Feature Specifics /// Not allowed pin codes. User won't be able to select one of the pin in the list. diff --git a/Riot/Managers/Settings/RiotSettings.swift b/Riot/Managers/Settings/RiotSettings.swift index 014f4502d..a984eda88 100644 --- a/Riot/Managers/Settings/RiotSettings.swift +++ b/Riot/Managers/Settings/RiotSettings.swift @@ -47,6 +47,7 @@ final class RiotSettings: NSObject { static let settingsSecurityScreenShowCryptographyInfo = "settingsSecurityScreenShowCryptographyInfo" static let settingsSecurityScreenShowCryptographyExport = "settingsSecurityScreenShowCryptographyExport" static let settingsSecurityScreenShowAdvancedUnverifiedDevices = "settingsSecurityScreenShowAdvancedBlacklistUnverifiedDevices" + static let allowInviteExernalUsers = "allowInviteExernalUsers" } static let shared = RiotSettings() @@ -72,6 +73,7 @@ final class RiotSettings: NSObject { defaults.removeObject(forKey: UserDefaultsKeys.settingsSecurityScreenShowCryptographyInfo) defaults.removeObject(forKey: UserDefaultsKeys.settingsSecurityScreenShowCryptographyExport) defaults.removeObject(forKey: UserDefaultsKeys.settingsSecurityScreenShowAdvancedUnverifiedDevices) + defaults.removeObject(forKey: UserDefaultsKeys.allowInviteExernalUsers) } // MARK: Servers @@ -236,6 +238,19 @@ final class RiotSettings: NSObject { } } + // MARK: Features + + var allowInviteExernalUsers: Bool { + get { + guard defaults.object(forKey: UserDefaultsKeys.allowInviteExernalUsers) != nil else { + return BuildSettings.allowInviteExernalUsers + } + return defaults.bool(forKey: UserDefaultsKeys.allowInviteExernalUsers) + } set { + defaults.set(newValue, forKey: UserDefaultsKeys.allowInviteExernalUsers) + } + } + // MARK: General Settings var settingsScreenShowChangePassword: Bool { diff --git a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m index 72d2e4616..dea3437ff 100644 --- a/Riot/Modules/Contacts/DataSources/ContactsDataSource.m +++ b/Riot/Modules/Contacts/DataSources/ContactsDataSource.m @@ -499,7 +499,7 @@ if (section == searchInputSection) { - count = 1; + count = RiotSettings.shared.allowInviteExernalUsers ? 1 : 0; } else if (section == filteredLocalContactsSection && !(shrinkedSectionsBitMask & CONTACTSDATASOURCE_LOCALCONTACTS_BITWISE)) { diff --git a/Riot/Modules/StartChat/StartChatViewController.m b/Riot/Modules/StartChat/StartChatViewController.m index eb35cd1fb..421ac343e 100644 --- a/Riot/Modules/StartChat/StartChatViewController.m +++ b/Riot/Modules/StartChat/StartChatViewController.m @@ -133,6 +133,12 @@ - (void)setupInviteFriendsHeaderView { + if (!RiotSettings.shared.allowInviteExernalUsers) + { + self.contactsTableView.tableHeaderView = nil; + return; + } + InviteFriendsHeaderView *inviteFriendsHeaderView = [InviteFriendsHeaderView instantiate]; inviteFriendsHeaderView.delegate = self; self.contactsTableView.tableHeaderView = inviteFriendsHeaderView; From e26acaaffbafc2c589aa876eed5c23e0a0c8fd8a Mon Sep 17 00:00:00 2001 From: Gil Eluard Date: Fri, 2 Apr 2021 11:49:02 +0200 Subject: [PATCH 2/2] Updated CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index 8855e8f83..6c1534a28 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -6,6 +6,7 @@ Changes to be released in next version 🙌 Improvements * Make the application settings more configurable (#4171) + * Enable / disable external friends invite (#4173) 🐛 Bugfix *