From d1b8ac06afb3f58c68f83a5063067ee2dd200631 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Sat, 17 Oct 2020 20:06:53 -0500 Subject: [PATCH] Ensure that the snapshot has items in it before testing section zero. --- iOS/MasterTimeline/MasterTimelineViewController.swift | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/iOS/MasterTimeline/MasterTimelineViewController.swift b/iOS/MasterTimeline/MasterTimelineViewController.swift index 224c1db09..5945dcf47 100644 --- a/iOS/MasterTimeline/MasterTimelineViewController.swift +++ b/iOS/MasterTimeline/MasterTimelineViewController.swift @@ -611,12 +611,14 @@ private extension MasterTimelineViewController { } tableView.selectRow(at: nil, animated: false, scrollPosition: .top) - if resetScroll && dataSource.snapshot().itemIdentifiers(inSection: 0).count > 0 { - tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false) + if resetScroll { + let snapshot = dataSource.snapshot() + if snapshot.sectionIdentifiers.count > 0 && snapshot.itemIdentifiers(inSection: 0).count > 0 { + tableView.scrollToRow(at: IndexPath(row: 0, section: 0), at: .top, animated: false) + } } updateToolbar() - } func updateToolbar() {