diff --git a/Riot/Modules/Favorites/FavouritesViewController.m b/Riot/Modules/Favorites/FavouritesViewController.m index eb9499359..49942eeed 100644 --- a/Riot/Modules/Favorites/FavouritesViewController.m +++ b/Riot/Modules/Favorites/FavouritesViewController.m @@ -130,9 +130,13 @@ [self.tableViewPaginationThrottler throttle:^{ NSInteger section = indexPath.section; + if (tableView.numberOfSections <= section) + { + return; + } + NSInteger numberOfRowsInSection = [tableView numberOfRowsInSection:section]; - if (tableView.numberOfSections > section - && indexPath.row == numberOfRowsInSection - 1) + if (indexPath.row == numberOfRowsInSection - 1) { [self->recentsDataSource paginateInSection:section]; } diff --git a/Riot/Modules/Home/HomeViewController.m b/Riot/Modules/Home/HomeViewController.m index 0f51fd248..22db94190 100644 --- a/Riot/Modules/Home/HomeViewController.m +++ b/Riot/Modules/Home/HomeViewController.m @@ -600,9 +600,13 @@ { [self.collectionViewPaginationThrottler throttle:^{ NSInteger collectionViewSection = indexPath.section; + if (collectionView.numberOfSections <= collectionViewSection) + { + return; + } + NSInteger numberOfItemsInSection = [collectionView numberOfItemsInSection:collectionViewSection]; - if (collectionView.numberOfSections > collectionViewSection - && indexPath.item == numberOfItemsInSection - 1) + if (indexPath.item == numberOfItemsInSection - 1) { NSInteger tableViewSection = collectionView.tag; [self->recentsDataSource paginateInSection:tableViewSection]; diff --git a/Riot/Modules/People/PeopleViewController.m b/Riot/Modules/People/PeopleViewController.m index fc6b5b69e..0f8152c5e 100644 --- a/Riot/Modules/People/PeopleViewController.m +++ b/Riot/Modules/People/PeopleViewController.m @@ -105,9 +105,13 @@ [self.tableViewPaginationThrottler throttle:^{ NSInteger section = indexPath.section; + if (tableView.numberOfSections <= section) + { + return; + } + NSInteger numberOfRowsInSection = [tableView numberOfRowsInSection:section]; - if (tableView.numberOfSections > section - && indexPath.row == numberOfRowsInSection - 1) + if (indexPath.row == numberOfRowsInSection - 1) { [self->recentsDataSource paginateInSection:section]; } diff --git a/Riot/Modules/Rooms/RoomsViewController.m b/Riot/Modules/Rooms/RoomsViewController.m index 6e4e066d5..f7b54cf6a 100644 --- a/Riot/Modules/Rooms/RoomsViewController.m +++ b/Riot/Modules/Rooms/RoomsViewController.m @@ -110,9 +110,13 @@ [self.tableViewPaginationThrottler throttle:^{ NSInteger section = indexPath.section; + if (tableView.numberOfSections <= section) + { + return; + } + NSInteger numberOfRowsInSection = [tableView numberOfRowsInSection:section]; - if (tableView.numberOfSections > section - && indexPath.row == numberOfRowsInSection - 1) + if (indexPath.row == numberOfRowsInSection - 1) { [self->recentsDataSource paginateInSection:section]; } diff --git a/changelog.d/5547.bugfix b/changelog.d/5547.bugfix new file mode 100644 index 000000000..570df2392 --- /dev/null +++ b/changelog.d/5547.bugfix @@ -0,0 +1 @@ +Home: Fix crash when pressing tabs