This commit is contained in:
Thomas Ricouard 2023-03-13 18:47:24 +01:00
parent aa120a48f7
commit 4f6f98271a
2 changed files with 7 additions and 1 deletions

View file

@ -72,6 +72,7 @@ public struct StatusDetailView: View {
.task {
guard !isLoaded else { return }
viewModel.client = client
viewModel.routerPath = routerPath
let result = await viewModel.fetch()
isLoaded = true

View file

@ -10,6 +10,7 @@ class StatusDetailViewModel: ObservableObject {
public var remoteStatusURL: URL?
var client: Client?
var routerPath: RouterPath?
enum State {
case loading, display(statuses: [Status], date: Date), error(error: Error)
@ -93,9 +94,13 @@ class StatusDetailViewModel: ObservableObject {
scrollToId = statusId
}
} catch {
if let error = error as? ServerError, error.httpCode == 404 {
_ = routerPath?.path.popLast()
} else {
state = .error(error: error)
}
}
}
private func fetchContextData(client: Client, statusId: String) async throws -> ContextData {
async let status: Status = client.get(endpoint: Statuses.status(id: statusId))