Don't reload relationship every time profile page switched
This commit is contained in:
parent
cdc64f1b2c
commit
50b84350d9
|
@ -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()
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue