Skip to content

Commit

Permalink
Fix PullRequestModel
Browse files Browse the repository at this point in the history
  • Loading branch information
winebarrel committed Nov 26, 2024
1 parent 426f698 commit fa70386
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Pulse/PullRequestAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func - (left: PullRequests, right: PullRequests) -> PullRequests {
return left.filter { !rightIDs.contains($0.id) }
}

struct PullRequestAPI {
actor PullRequestAPI {
private let client: ApolloClient

init(_ githubToken: String) {
Expand Down
25 changes: 23 additions & 2 deletions Pulse/PullRequestModel.swift
Original file line number Diff line number Diff line change
@@ -1,12 +1,33 @@
import Foundation
import SwiftUI

@MainActor
class PullRequestModel: ObservableObject {
// TODO:

Check warning on line 6 in Pulse/PullRequestModel.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
@AppStorage("githubQuery") private var githubQuery = Constants.defaultGithubQuery
@Published var settled: PullRequests = []
@Published var pending: PullRequests = []
@Published var updatedAt: Date?
@Published var error: GitHubError?

func update(_ api: PullRequestAPI) async {
// TODO:
updatedAt = Date()
do {
let pulls = try await api.fetch(githubQuery)

for pull in pulls {
if pull.pending {
pending.append(pull)
} else {
settled.append(pull)
}
}

// TODO:

Check warning on line 25 in Pulse/PullRequestModel.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
updatedAt = Date()
} catch let ghErr as GitHubError {
error = ghErr
} catch {
Logger.shared.error("failed to get pull requests: \(error)")
}
}
}

0 comments on commit fa70386

Please sign in to comment.