import Foundation import Observation /// `repo bookmarks` — the caller's public bookmarks, in server order. /// The rows decode as `RepoSummary`; a repository made private since it /// was bookmarked is already left out by the server. @Observable @MainActor final class BookmarkListViewModel { private(set) var state: LoadState<[RepoSummary]> = .loading private let client: GitbayClient init(client: GitbayClient) { self.client = client } func load() async { state = .loading do { let repos = try await client.readList(["repo", "bookmarks"], of: RepoSummary.self) state = repos.isEmpty ? .empty("No bookmarks yet. Bookmark a repository from its actions menu.") : .loaded(repos) } catch { state = .from(error) } } }