Add discourage view when server doesn't support threads

This commit is contained in:
ismailgulek 2022-04-19 13:32:15 +03:00
parent 8a687396df
commit 9348e11dc8
No known key found for this signature in database
GPG key ID: E96336D42D9470A9

View file

@ -187,7 +187,8 @@ SingleImagePickerPresenterDelegate,
SettingsDiscoveryTableViewSectionDelegate, SettingsDiscoveryViewModelCoordinatorDelegate,
SettingsIdentityServerCoordinatorBridgePresenterDelegate,
ServiceTermsModalCoordinatorBridgePresenterDelegate,
TableViewSectionsDelegate>
TableViewSectionsDelegate,
ThreadsBetaCoordinatorBridgePresenterDelegate>
{
// Current alert (if any).
__weak UIAlertController *currentAlert;
@ -288,6 +289,8 @@ TableViewSectionsDelegate>
@property (nonatomic, strong) UserInteractiveAuthenticationService *userInteractiveAuthenticationService;
@property (nonatomic, strong) ThreadsBetaCoordinatorBridgePresenter *threadsBetaBridgePresenter;
/**
Whether or not to check for contacts access after the user accepts the service terms. The value of this property is
set automatically when calling `prepareIdentityServiceAndPresentTermsWithSession:checkingAccessForContactsOnAccept`
@ -3254,8 +3257,31 @@ TableViewSectionsDelegate>
- (void)toggleEnableThreads:(UISwitch *)sender
{
RiotSettings.shared.enableThreads = sender.isOn;
MXSDKOptions.sharedInstance.enableThreads = sender.isOn;
if (sender.isOn && !self.mainSession.store.supportedMatrixVersions.supportsThreads)
{
// user wants to turn on the threads setting but the server does not support it
if (self.threadsBetaBridgePresenter)
{
[self.threadsBetaBridgePresenter dismissWithAnimated:YES completion:nil];
self.threadsBetaBridgePresenter = nil;
}
self.threadsBetaBridgePresenter = [[ThreadsBetaCoordinatorBridgePresenter alloc] initWithThreadId:@""
infoText:VectorL10n.threadsDiscourageInformation1
additionalText:VectorL10n.threadsDiscourageInformation2];
self.threadsBetaBridgePresenter.delegate = self;
[self.threadsBetaBridgePresenter presentFrom:self.presentedViewController?:self animated:YES];
return;
}
[self enableThreads:sender.isOn];
}
- (void)enableThreads:(BOOL)enable
{
RiotSettings.shared.enableThreads = enable;
MXSDKOptions.sharedInstance.enableThreads = enable;
[[MXKRoomDataSourceManager sharedManagerForMatrixSession:self.mainSession] reset];
[[AppDelegate theDelegate] restoreEmptyDetailsViewController];
}
@ -4724,4 +4750,24 @@ TableViewSectionsDelegate>
[self.tableView reloadData];
}
#pragma mark - ThreadsBetaCoordinatorBridgePresenterDelegate
- (void)threadsBetaCoordinatorBridgePresenterDelegateDidTapEnable:(ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
MXWeakify(self);
[self.threadsBetaBridgePresenter dismissWithAnimated:YES completion:^{
MXStrongifyAndReturnIfNil(self);
[self enableThreads:YES];
}];
}
- (void)threadsBetaCoordinatorBridgePresenterDelegateDidTapCancel:(ThreadsBetaCoordinatorBridgePresenter *)coordinatorBridgePresenter
{
MXWeakify(self);
[self.threadsBetaBridgePresenter dismissWithAnimated:YES completion:^{
MXStrongifyAndReturnIfNil(self);
[self updateSections];
}];
}
@end