From baa9dfe0f13f1b459ea7926307223879afad3660 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 16 Jan 2023 15:51:03 -0500 Subject: [PATCH] More logging --- .../Timeline/TimelineViewController.swift | 47 ++++++++++++++----- 1 file changed, 35 insertions(+), 12 deletions(-) diff --git a/Tusker/Screens/Timeline/TimelineViewController.swift b/Tusker/Screens/Timeline/TimelineViewController.swift index e85f83cb..953e25f2 100644 --- a/Tusker/Screens/Timeline/TimelineViewController.swift +++ b/Tusker/Screens/Timeline/TimelineViewController.swift @@ -355,10 +355,26 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro @MainActor private func loadStatusesToRestore(position: TimelinePosition) async -> Bool { + { + let crumb = Breadcrumb(level: .info, category: "TimelineViewController") + crumb.message = "Original statusIDs before filtering" + crumb.data = [ + "statusIDs": position.statusIDs, + ] + SentrySDK.addBreadcrumb(crumb: crumb) + }() let unloaded = position.statusIDs.filter({ mastodonController.persistentContainer.status(for: $0) == nil }) guard !unloaded.isEmpty else { return true } + { + let crumb = Breadcrumb(level: .info, category: "TimelineViewController") + crumb.message = "Unloaded ids" + crumb.data = [ + "unloaded": unloaded + ] + SentrySDK.addBreadcrumb(crumb: crumb) + }() let results = await withTaskGroup(of: (String, Result).self) { group -> [(String, Result)] in for id in unloaded { group.addTask { @@ -379,6 +395,9 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro switch result { case .success(let status): statuses.append(status) + let crumb = Breadcrumb(level: .info, category: "TimelineViewController") + crumb.message = "Loaded status \(id)" + SentrySDK.addBreadcrumb(crumb: crumb) case .failure(let error): let crumb = Breadcrumb(level: .error, category: "TimelineViewController") crumb.message = "Error loading status" @@ -391,12 +410,14 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro } await mastodonController.persistentContainer.addAll(statuses: statuses, in: mastodonController.persistentContainer.viewContext) - let crumb = Breadcrumb(level: .info, category: "TimelineViewController") - crumb.message = "Original position statusIDs" - crumb.data = [ - "statusIDs": position.statusIDs, - ] - SentrySDK.addBreadcrumb(crumb: crumb) + _ = { + let crumb = Breadcrumb(level: .info, category: "TimelineViewController") + crumb.message = "Position statusIDs before filtering" + crumb.data = [ + "statusIDs": position.statusIDs, + ] + SentrySDK.addBreadcrumb(crumb: crumb) + }() // update the timeline position in case some statuses couldn't be loaded if let center = position.centerStatusID { @@ -410,12 +431,14 @@ class TimelineViewController: UIViewController, TimelineLikeCollectionViewContro !unloaded.contains(id) || statuses.contains(where: { $0.id == id }) } - let crumb2 = Breadcrumb(level: .info, category: "TimelineViewController") - crumb2.message = "Filtered position statusIDs" - crumb2.data = [ - "statusIDs": position.statusIDs, - ] - SentrySDK.addBreadcrumb(crumb: crumb2) + { + let crumb = Breadcrumb(level: .info, category: "TimelineViewController") + crumb.message = "Filtered position statusIDs" + crumb.data = [ + "statusIDs": position.statusIDs, + ] + SentrySDK.addBreadcrumb(crumb: crumb) + }() return !position.statusIDs.isEmpty }