mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
Forward error
This commit is contained in:
parent
ec8de5fb83
commit
e91a8b4b0a
2 changed files with 5 additions and 5 deletions
|
@ -13,8 +13,8 @@ public struct TimelineView: View {
|
||||||
switch viewModel.state {
|
switch viewModel.state {
|
||||||
case .loading:
|
case .loading:
|
||||||
loadingRow
|
loadingRow
|
||||||
case .error:
|
case let .error(error):
|
||||||
Text("An error occurred, please try to refresh")
|
Text(error.localizedDescription)
|
||||||
case let .display(statuses, nextPageState):
|
case let .display(statuses, nextPageState):
|
||||||
ForEach(statuses) { status in
|
ForEach(statuses) { status in
|
||||||
StatusRowView(status: status)
|
StatusRowView(status: status)
|
||||||
|
|
|
@ -9,7 +9,7 @@ class TimelineViewModel: ObservableObject {
|
||||||
}
|
}
|
||||||
case loading
|
case loading
|
||||||
case display(statuses: [Status], nextPageState: State.PadingState)
|
case display(statuses: [Status], nextPageState: State.PadingState)
|
||||||
case error
|
case error(error: Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
private let client: Client
|
private let client: Client
|
||||||
|
@ -30,7 +30,7 @@ class TimelineViewModel: ObservableObject {
|
||||||
statuses = try await client.fetchArray(endpoint: Timeline.pub(sinceId: nil))
|
statuses = try await client.fetchArray(endpoint: Timeline.pub(sinceId: nil))
|
||||||
state = .display(statuses: statuses, nextPageState: .hasNextPage)
|
state = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||||
} catch {
|
} catch {
|
||||||
print(error.localizedDescription)
|
state = .error(error: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class TimelineViewModel: ObservableObject {
|
||||||
statuses.append(contentsOf: newStatuses)
|
statuses.append(contentsOf: newStatuses)
|
||||||
state = .display(statuses: statuses, nextPageState: .hasNextPage)
|
state = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||||
} catch {
|
} catch {
|
||||||
print(error.localizedDescription)
|
state = .error(error: error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue