From 50b84350d99f0e4d071bae3378059c189a4bb1c3 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Thu, 11 Jul 2024 22:31:42 -0700 Subject: [PATCH] Don't reload relationship every time profile page switched --- .../ProfileStatusesViewController.swift | 20 ------------------- .../Profile/ProfileViewController.swift | 19 ++++++++++++++++++ 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/Tusker/Screens/Profile/ProfileStatusesViewController.swift b/Tusker/Screens/Profile/ProfileStatusesViewController.swift index a4880a6feb..c7764ed9b0 100644 --- a/Tusker/Screens/Profile/ProfileStatusesViewController.swift +++ b/Tusker/Screens/Profile/ProfileStatusesViewController.swift @@ -9,12 +9,6 @@ import UIKit import Pachyderm import Combine -import OSLog -#if canImport(Sentry) -import Sentry -#endif - -private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ProfileStatusesViewController") class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionViewController, CollectionViewController { @@ -255,20 +249,6 @@ class ProfileStatusesViewController: UIViewController, TimelineLikeCollectionVie state = .setupInitialSnapshot - Task { - do { - let (all, _) = try await mastodonController.run(Client.getRelationships(accounts: [accountID])) - if let relationship = all.first { - self.mastodonController.persistentContainer.addOrUpdate(relationship: relationship) - } - } catch { - logger.error("Error fetching relationship: \(String(describing: error))") - #if canImport(Sentry) - SentrySDK.capture(error: error) - #endif - } - } - await controller.loadInitial() await tryLoadPinned() diff --git a/Tusker/Screens/Profile/ProfileViewController.swift b/Tusker/Screens/Profile/ProfileViewController.swift index 26d5c57810..f4266c74d6 100644 --- a/Tusker/Screens/Profile/ProfileViewController.swift +++ b/Tusker/Screens/Profile/ProfileViewController.swift @@ -9,6 +9,12 @@ import UIKit import Pachyderm import Combine +import OSLog +#if canImport(Sentry) +import Sentry +#endif + +private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "ProfileViewController") class ProfileViewController: UIViewController, StateRestorableViewController { @@ -120,6 +126,19 @@ class ProfileViewController: UIViewController, StateRestorableViewController { guard let accountID else { return } + Task { + do { + let (all, _) = try await mastodonController.run(Client.getRelationships(accounts: [accountID])) + if let relationship = all.first { + self.mastodonController.persistentContainer.addOrUpdate(relationship: relationship) + } + } catch { + logger.error("Error fetching relationship: \(String(describing: error))") + #if canImport(Sentry) + SentrySDK.capture(error: error) + #endif + } + } if let account = mastodonController.persistentContainer.account(for: accountID) { updateAccountUI(account: account) } else {