From 19e5dd5412504f2f9313367ddf07b49a64d9d0ab Mon Sep 17 00:00:00 2001 From: ismailgulek Date: Wed, 15 Jul 2020 16:13:59 +0300 Subject: [PATCH 1/2] Scroll to next section if discovery is not ready yet, fixes #3401 --- Riot/Modules/Settings/SettingsViewController.m | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Riot/Modules/Settings/SettingsViewController.m b/Riot/Modules/Settings/SettingsViewController.m index be33654b8..ce8b9e58b 100644 --- a/Riot/Modules/Settings/SettingsViewController.m +++ b/Riot/Modules/Settings/SettingsViewController.m @@ -2471,8 +2471,18 @@ SettingsIdentityServerCoordinatorBridgePresenterDelegate> } else if (section == SETTINGS_SECTION_USER_SETTINGS_INDEX && row == userSettingsThreePidsInformation) { - NSIndexPath *discoveryIndexPath = [NSIndexPath indexPathForRow:0 inSection:SETTINGS_SECTION_DISCOVERY_INDEX]; - [tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; + // settingsDiscoveryTableViewSection is a dynamic section, so check number of rows before scroll to avoid crashes + if (self.settingsDiscoveryTableViewSection.numberOfRows > 0) + { + NSIndexPath *discoveryIndexPath = [NSIndexPath indexPathForRow:0 inSection:SETTINGS_SECTION_DISCOVERY_INDEX]; + [tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionTop animated:YES]; + } + else + { + // this won't be precise in scroll location, but seems the best option for now + NSIndexPath *discoveryIndexPath = [NSIndexPath indexPathForRow:0 inSection:SETTINGS_SECTION_DISCOVERY_INDEX + 1]; + [tableView scrollToRowAtIndexPath:discoveryIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; + } } else if (section == SETTINGS_SECTION_DISCOVERY_INDEX) { From 0103eb32e2184885e5d85b67984703f965e9c4fa Mon Sep 17 00:00:00 2001 From: ismailgulek Date: Wed, 15 Jul 2020 16:14:42 +0300 Subject: [PATCH 2/2] Update CHANGES.rst --- CHANGES.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.rst b/CHANGES.rst index dab2ce787..97414fcac 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -31,6 +31,7 @@ Bug fix: * Xcode11: Disable voip background mode to avoid VoIP pushes (#3369). * Xcode11: Disable key backup on push extension (#3371). * RoomMembershipBubbleCell: Fix message textview leading constraint (#3226). + * SettingsViewController: Fix crash when scrolling to Discovery (#3401). Changes in 0.11.6 (2020-06-30) ===============================================