mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-22 16:31:00 +00:00
Remove needless fetchArray
This commit is contained in:
parent
e91a8b4b0a
commit
4742e3112b
2 changed files with 1 additions and 6 deletions
|
@ -31,9 +31,4 @@ public class Client: ObservableObject {
|
||||||
let (data, _) = try await urlSession.data(from: makeURL(endpoint: endpoint))
|
let (data, _) = try await urlSession.data(from: makeURL(endpoint: endpoint))
|
||||||
return try decoder.decode(Entity.self, from: data)
|
return try decoder.decode(Entity.self, from: data)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func fetchArray<Entity: Codable>(endpoint: Endpoint) async throws -> [Entity] {
|
|
||||||
let (data, _) = try await urlSession.data(from: makeURL(endpoint: endpoint))
|
|
||||||
return try decoder.decode([Entity].self, from: data)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ class TimelineViewModel: ObservableObject {
|
||||||
|
|
||||||
func refreshTimeline() async {
|
func refreshTimeline() async {
|
||||||
do {
|
do {
|
||||||
statuses = try await client.fetchArray(endpoint: Timeline.pub(sinceId: nil))
|
statuses = try await client.fetch(endpoint: Timeline.pub(sinceId: nil))
|
||||||
state = .display(statuses: statuses, nextPageState: .hasNextPage)
|
state = .display(statuses: statuses, nextPageState: .hasNextPage)
|
||||||
} catch {
|
} catch {
|
||||||
state = .error(error: error)
|
state = .error(error: error)
|
||||||
|
|
Loading…
Reference in a new issue