diff --git a/Riot/Assets/en.lproj/Vector.strings b/Riot/Assets/en.lproj/Vector.strings index cad2a247f..67a3384ef 100644 --- a/Riot/Assets/en.lproj/Vector.strings +++ b/Riot/Assets/en.lproj/Vector.strings @@ -555,6 +555,7 @@ // Security settings "security_settings_title" = "Security"; "security_settings_crypto_sessions" = "MY SESSIONS"; +"security_settings_crypto_sessions_loading" = "Loading sessions…"; "security_settings_crypto_sessions_description" = "Trust sessions to grant access to end-to-end encrypted messages. If you don’t recognise a session, change your login password and reset your Message Password used for Message Backup."; "security_settings_backup" = "MESSAGE BACKUP"; diff --git a/Riot/Generated/Strings.swift b/Riot/Generated/Strings.swift index efecdaccb..ab61ffc81 100644 --- a/Riot/Generated/Strings.swift +++ b/Riot/Generated/Strings.swift @@ -2702,6 +2702,10 @@ internal enum VectorL10n { internal static var securitySettingsCryptoSessionsDescription: String { return VectorL10n.tr("Vector", "security_settings_crypto_sessions_description") } + /// Loading sessions… + internal static var securitySettingsCryptoSessionsLoading: String { + return VectorL10n.tr("Vector", "security_settings_crypto_sessions_loading") + } /// Export keys manually internal static var securitySettingsExportKeysManually: String { return VectorL10n.tr("Vector", "security_settings_export_keys_manually") diff --git a/Riot/Modules/Settings/Security/SecurityViewController.m b/Riot/Modules/Settings/Security/SecurityViewController.m index 422562218..cae168391 100644 --- a/Riot/Modules/Settings/Security/SecurityViewController.m +++ b/Riot/Modules/Settings/Security/SecurityViewController.m @@ -85,6 +85,8 @@ UIDocumentInteractionControllerDelegate> KeyBackupRecoverCoordinatorBridgePresenter *keyBackupRecoverCoordinatorBridgePresenter; } +@property (nonatomic) BOOL isLoadingDevices; + @end @implementation SecurityViewController @@ -228,6 +230,11 @@ UIDocumentInteractionControllerDelegate> #pragma mark - Internal methods +- (BOOL)showLoadingDevicesInformation +{ + return self.isLoadingDevices && devicesArray.count == 0; +} + - (void)pushViewController:(UIViewController*)viewController { // Keep ref on pushed view controller @@ -361,10 +368,14 @@ UIDocumentInteractionControllerDelegate> - (void)loadDevices { + self.isLoadingDevices = YES; + // Refresh the account devices list MXWeakify(self); [self.mainSession.matrixRestClient devices:^(NSArray *devices) { MXStrongifyAndReturnIfNil(self); + + self.isLoadingDevices = NO; if (devices) { @@ -400,6 +411,8 @@ UIDocumentInteractionControllerDelegate> } failure:^(NSError *error) { + self.isLoadingDevices = NO; + // Display the data that has been loaded last time // Note: The use of 'reloadData' handles the case where the account has been logged out. [self reloadData]; @@ -437,7 +450,14 @@ UIDocumentInteractionControllerDelegate> switch (section) { case SECTION_CRYPTO_SESSIONS: - count = devicesArray.count + 1; + if (self.showLoadingDevicesInformation) + { + count = 2; + } + else + { + count = devicesArray.count + 1; + } break; case SECTION_KEYBACKUP: count = keyBackupSection.numberOfRows; @@ -563,15 +583,31 @@ UIDocumentInteractionControllerDelegate> MXSession* session = self.mainSession; if (section == SECTION_CRYPTO_SESSIONS) { - if (row < devicesArray.count) + if (self.showLoadingDevicesInformation) { - cell = [self deviceCellWithDevice:devicesArray[row] forTableView:tableView]; + if (indexPath.row == 0) + { + cell = [self descriptionCellForTableView:tableView + withText:NSLocalizedStringFromTable(@"security_settings_crypto_sessions_loading", @"Vector", nil) ]; + } + else + { + cell = [self descriptionCellForTableView:tableView + withText:NSLocalizedStringFromTable(@"security_settings_crypto_sessions_description", @"Vector", nil) ]; + } } - else if (row == devicesArray.count) + else { - cell = [self descriptionCellForTableView:tableView - withText:NSLocalizedStringFromTable(@"security_settings_crypto_sessions_description", @"Vector", nil) ]; - + if (row < devicesArray.count) + { + cell = [self deviceCellWithDevice:devicesArray[row] forTableView:tableView]; + } + else if (row == devicesArray.count) + { + cell = [self descriptionCellForTableView:tableView + withText:NSLocalizedStringFromTable(@"security_settings_crypto_sessions_description", @"Vector", nil) ]; + + } } } else if (section == SECTION_ADVANCED)