Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #2518: Crash when favorites are inserted to NTP. (#2520)
Browse files Browse the repository at this point in the history
  • Loading branch information
iccub authored May 7, 2020
1 parent 13ab017 commit eae2b59
Showing 1 changed file with 2 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,9 @@ extension FavoritesDataSource: NSFetchedResultsControllerDelegate {
}

func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?) {

switch type {
case .insert:
// Do not insert to collection view if full row is already taken,
// otherwise it crashes with inconsistency exception.
if let indexPath = newIndexPath, indexPath.row < columnsPerRow {
collectionView?.insertItems(at: [indexPath])
}

favoriteUpdatedHandler?()
case .delete:
case .insert, .delete:
// Not all favorites must be visible at the time, so we can't just call `deleteItems` here.
// Example:
// There's 10 favorites total, 4 are visible on iPhone.
Expand Down

0 comments on commit eae2b59

Please sign in to comment.