diff --git a/Vernissage/Views/StatusView.swift b/Vernissage/Views/StatusView.swift index f3a3887..eee65e5 100644 --- a/Vernissage/Views/StatusView.swift +++ b/Vernissage/Views/StatusView.swift @@ -17,6 +17,7 @@ struct StatusView: View { @State private var messageForStatus: StatusViewModel? @State private var showCompose = false + @State private var firstLoadFinished = false @State private var statusViewModel: StatusViewModel? @@ -97,6 +98,10 @@ struct StatusView: View { }) .task { do { + guard firstLoadFinished == false else { + return + } + // Get status from API. if let status = try await TimelineService.shared.getStatus(withId: self.statusId, and: self.applicationState.accountData) { let statusViewModel = StatusViewModel(status: status) @@ -110,6 +115,7 @@ struct StatusView: View { } self.statusViewModel = statusViewModel + self.firstLoadFinished = true // If we have status in database then we can update data. if let accountData = self.applicationState.accountData, diff --git a/Vernissage/Views/UserProfileView.swift b/Vernissage/Views/UserProfileView.swift index 61f1b71..73207d0 100644 --- a/Vernissage/Views/UserProfileView.swift +++ b/Vernissage/Views/UserProfileView.swift @@ -15,6 +15,7 @@ struct UserProfileView: View { @State public var accountUserName: String @State private var account: Account? = nil @State private var relationship: Relationship? = nil + @State private var firstLoadFinished = false var body: some View { VStack { @@ -40,10 +41,15 @@ struct UserProfileView: View { } private func loadData() async throws { + guard firstLoadFinished == false else { + return + } + async let relationshipTask = AccountService.shared.getRelationship(withId: self.accountId, forUser: self.applicationState.accountData) async let accountTask = AccountService.shared.getAccount(withId: self.accountId, and: self.applicationState.accountData) // Wait for download account and relationships. + self.firstLoadFinished = true (self.relationship, self.account) = try await (relationshipTask, accountTask) } } diff --git a/Vernissage/Widgets/UserProfileStatuses.swift b/Vernissage/Widgets/UserProfileStatuses.swift index 1809bd8..829d06a 100644 --- a/Vernissage/Widgets/UserProfileStatuses.swift +++ b/Vernissage/Widgets/UserProfileStatuses.swift @@ -59,6 +59,10 @@ struct UserProfileStatuses: View { } private func loadStatuses() async throws { + guard firstLoadFinished == false else { + return + } + let statuses = try await AccountService.shared.getStatuses( forAccountId: self.accountId, andContext: self.applicationState.accountData,