@@ -187,7 +187,8 @@ @interface SettingsViewController () <UITextFieldDelegate, MXKCountryPickerViewC
187187SettingsDiscoveryTableViewSectionDelegate, SettingsDiscoveryViewModelCoordinatorDelegate,
188188SettingsIdentityServerCoordinatorBridgePresenterDelegate,
189189ServiceTermsModalCoordinatorBridgePresenterDelegate,
190- TableViewSectionsDelegate>
190+ TableViewSectionsDelegate,
191+ ThreadsBetaCoordinatorBridgePresenterDelegate>
191192{
192193 // Current alert (if any).
193194 __weak UIAlertController *currentAlert;
@@ -288,6 +289,8 @@ @interface SettingsViewController () <UITextFieldDelegate, MXKCountryPickerViewC
288289
289290@property (nonatomic , strong ) UserInteractiveAuthenticationService *userInteractiveAuthenticationService;
290291
292+ @property (nonatomic , strong ) ThreadsBetaCoordinatorBridgePresenter *threadsBetaBridgePresenter;
293+
291294/* *
292295 Whether or not to check for contacts access after the user accepts the service terms. The value of this property is
293296 set automatically when calling `prepareIdentityServiceAndPresentTermsWithSession:checkingAccessForContactsOnAccept`
@@ -3254,8 +3257,31 @@ - (void)toggleEnableRingingForGroupCalls:(UISwitch *)sender
32543257
32553258- (void )toggleEnableThreads : (UISwitch *)sender
32563259{
3257- RiotSettings.shared .enableThreads = sender.isOn ;
3258- MXSDKOptions.sharedInstance .enableThreads = sender.isOn ;
3260+ if (sender.isOn && !self.mainSession .store .supportedMatrixVersions .supportsThreads )
3261+ {
3262+ // user wants to turn on the threads setting but the server does not support it
3263+ if (self.threadsBetaBridgePresenter )
3264+ {
3265+ [self .threadsBetaBridgePresenter dismissWithAnimated: YES completion: nil ];
3266+ self.threadsBetaBridgePresenter = nil ;
3267+ }
3268+
3269+ self.threadsBetaBridgePresenter = [[ThreadsBetaCoordinatorBridgePresenter alloc ] initWithThreadId: @" "
3270+ infoText: VectorL10n.threadsDiscourageInformation1
3271+ additionalText: VectorL10n.threadsDiscourageInformation2];
3272+ self.threadsBetaBridgePresenter .delegate = self;
3273+
3274+ [self .threadsBetaBridgePresenter presentFrom: self .presentedViewController?:self animated: YES ];
3275+ return ;
3276+ }
3277+
3278+ [self enableThreads: sender.isOn];
3279+ }
3280+
3281+ - (void )enableThreads : (BOOL )enable
3282+ {
3283+ RiotSettings.shared .enableThreads = enable;
3284+ MXSDKOptions.sharedInstance .enableThreads = enable;
32593285 [[MXKRoomDataSourceManager sharedManagerForMatrixSession: self .mainSession] reset ];
32603286 [[AppDelegate theDelegate ] restoreEmptyDetailsViewController ];
32613287}
@@ -4724,4 +4750,24 @@ - (void)tableViewSectionsDidUpdateSections:(TableViewSections *)sections
47244750 [self .tableView reloadData ];
47254751}
47264752
4753+ #pragma mark - ThreadsBetaCoordinatorBridgePresenterDelegate
4754+
4755+ - (void )threadsBetaCoordinatorBridgePresenterDelegateDidTapEnable : (ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter
4756+ {
4757+ MXWeakify (self);
4758+ [self .threadsBetaBridgePresenter dismissWithAnimated: YES completion: ^{
4759+ MXStrongifyAndReturnIfNil (self);
4760+ [self enableThreads: YES ];
4761+ }];
4762+ }
4763+
4764+ - (void )threadsBetaCoordinatorBridgePresenterDelegateDidTapCancel : (ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter
4765+ {
4766+ MXWeakify (self);
4767+ [self .threadsBetaBridgePresenter dismissWithAnimated: YES completion: ^{
4768+ MXStrongifyAndReturnIfNil (self);
4769+ [self updateSections ];
4770+ }];
4771+ }
4772+
47274773@end
0 commit comments