Merge pull request #2051 from vector-im/ll_by_default

SettingsVC: Use MXKAccount method to determine if LL is supported by the HS
This commit is contained in:
manuroe
2018-09-25 16:22:31 +02:00
committed by GitHub
3 changed files with 34 additions and 40 deletions
+1
View File
@@ -3,6 +3,7 @@ Changes in 0.7.4 (2018-09-)
Improvements:
* Upgrade MatrixKit version (v0.8.4).
* Lazy loading: Enable it by default (if the homeserver supports it).
* i18n: Add Spanish (sp).
* Settings: Make advanced info copyable (#2023).
* Settings: Made cryptography info copyable, thanks to @daverPL (PR #1999).
+2
View File
@@ -2683,6 +2683,8 @@ NSString *const kAppDelegateNetworkStatusDidChangeNotification = @"kAppDelegateN
[_masterTabBarController showAuthenticationScreen];
// Note: Keep App settings
// But enforce usage of member lazy loading
[MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers = YES;
// Reset the contact manager
[[MXKContactManager sharedManager] reset];
+31 -40
View File
@@ -2059,7 +2059,9 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
MXKTableViewCellWithLabelAndSwitch* labelAndSwitchCell = [self getLabelAndSwitchCell:tableView forIndexPath:indexPath];
labelAndSwitchCell.mxkLabel.text = NSLocalizedStringFromTable(@"settings_labs_room_members_lazy_loading", @"Vector", nil);
labelAndSwitchCell.mxkSwitch.on = [MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers;
MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject;
labelAndSwitchCell.mxkSwitch.on = account.mxSession.syncWithLazyLoadOfRoomMembers;
[labelAndSwitchCell.mxkSwitch addTarget:self action:@selector(toggleSyncWithLazyLoadOfRoomMembers:) forControlEvents:UIControlEventTouchUpInside];
@@ -2924,54 +2926,43 @@ typedef void (^blockSettingsViewController_onReadyToDestroy)();
[self startActivityIndicator];
// Check the user homeserver supports lazy-loading
MXSession* session = [AppDelegate theDelegate].mxSessions.firstObject;
MXKAccount* account = [MXKAccountManager sharedManager].activeAccounts.firstObject;
MXWeakify(self);
void(^onFailure)(NSError *) = ^(NSError *error) {
[account supportLazyLoadOfRoomMembers:^(BOOL supportLazyLoadOfRoomMembers) {
MXStrongifyAndReturnIfNil(self);
[switchButton setOn:NO animated:YES];
switchButton.enabled = YES;
[self stopActivityIndicator];
// No support of lazy-loading, do not engage it and warn the user
[self->currentAlert dismissViewControllerAnimated:NO completion:nil];
self->currentAlert = [UIAlertController alertControllerWithTitle:nil
message:NSLocalizedStringFromTable(@"settings_labs_room_members_lazy_loading_error_message", @"Vector", nil)
preferredStyle:UIAlertControllerStyleAlert];
MXWeakify(self);
[self->currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
}]];
[self->currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCNoHSSupportOfLazyLoading"];
[self presentViewController:self->currentAlert animated:YES completion:nil];
};
// Check first the home server supports m.lazy_load_members
[session supportedMatrixVersions:^(MXMatrixVersions *matrixVersions) {
if (matrixVersions.supportLazyLoadMembers)
if (supportLazyLoadOfRoomMembers)
{
// Check then, we can create a LL filter on it
[session setFilter:[MXFilterJSONModel syncFilterForLazyLoading] success:^(NSString *filterId) {
// Lazy-loading is fully supported, enable it
[MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers = YES;
[self launchClearCache];
} failure:onFailure];
// Lazy-loading is fully supported, enable it
[MXKAppSettings standardAppSettings].syncWithLazyLoadOfRoomMembers = YES;
[self launchClearCache];
}
else
{
onFailure(nil);
[switchButton setOn:NO animated:YES];
switchButton.enabled = YES;
[self stopActivityIndicator];
// No support of lazy-loading, do not engage it and warn the user
[self->currentAlert dismissViewControllerAnimated:NO completion:nil];
self->currentAlert = [UIAlertController alertControllerWithTitle:nil
message:NSLocalizedStringFromTable(@"settings_labs_room_members_lazy_loading_error_message", @"Vector", nil)
preferredStyle:UIAlertControllerStyleAlert];
MXWeakify(self);
[self->currentAlert addAction:[UIAlertAction actionWithTitle:[NSBundle mxk_localizedStringForKey:@"ok"]
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
MXStrongifyAndReturnIfNil(self);
self->currentAlert = nil;
}]];
[self->currentAlert mxk_setAccessibilityIdentifier: @"SettingsVCNoHSSupportOfLazyLoading"];
[self presentViewController:self->currentAlert animated:YES completion:nil];
}
} failure:onFailure];
}];
}
}
}