mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-29 11:41:01 +00:00
Fix #1236
This commit is contained in:
parent
aa120a48f7
commit
4f6f98271a
2 changed files with 7 additions and 1 deletions
|
@ -72,6 +72,7 @@ public struct StatusDetailView: View {
|
||||||
.task {
|
.task {
|
||||||
guard !isLoaded else { return }
|
guard !isLoaded else { return }
|
||||||
viewModel.client = client
|
viewModel.client = client
|
||||||
|
viewModel.routerPath = routerPath
|
||||||
let result = await viewModel.fetch()
|
let result = await viewModel.fetch()
|
||||||
isLoaded = true
|
isLoaded = true
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ class StatusDetailViewModel: ObservableObject {
|
||||||
public var remoteStatusURL: URL?
|
public var remoteStatusURL: URL?
|
||||||
|
|
||||||
var client: Client?
|
var client: Client?
|
||||||
|
var routerPath: RouterPath?
|
||||||
|
|
||||||
enum State {
|
enum State {
|
||||||
case loading, display(statuses: [Status], date: Date), error(error: Error)
|
case loading, display(statuses: [Status], date: Date), error(error: Error)
|
||||||
|
@ -93,9 +94,13 @@ class StatusDetailViewModel: ObservableObject {
|
||||||
scrollToId = statusId
|
scrollToId = statusId
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
if let error = error as? ServerError, error.httpCode == 404 {
|
||||||
|
_ = routerPath?.path.popLast()
|
||||||
|
} else {
|
||||||
state = .error(error: error)
|
state = .error(error: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private func fetchContextData(client: Client, statusId: String) async throws -> ContextData {
|
private func fetchContextData(client: Client, statusId: String) async throws -> ContextData {
|
||||||
async let status: Status = client.get(endpoint: Statuses.status(id: statusId))
|
async let status: Status = client.get(endpoint: Statuses.status(id: statusId))
|
||||||
|
|
Loading…
Reference in a new issue