a native ios client for gitbay

client ios swift

https://gitbay.org

gitbay/Dashboard/DashboardViewModel.swift

ui-smoke
gitbay-ios/gitbay/Dashboard/DashboardViewModel.swift history · blame · raw

27 lines · 710 bytes

 1import Foundation
 2import Observation
 3
 4/// The web dashboard contract  attention queues, open work, pins, and
 5/// recent activity  in one `dashboard` read. This replaced a per-repo fan-out that
 6/// drained the rate bucket at 64 of 66 repos; krz/gitbay#41 added the
 7/// aggregate.
 8@Observable
 9@MainActor
10final class DashboardViewModel {
11
12    private(set) var state: LoadState<DashboardData> = .loading
13
14    private let client: GitbayClient
15
16    init(client: GitbayClient) {
17        self.client = client
18    }
19
20    func load() async {
21        do {
22            state = .loaded(try await client.read(["dashboard"], as: DashboardData.self))
23        } catch {
24            state = .from(error)
25        }
26    }
27}