Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add error view #42

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions Pulse/ContentListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,22 @@

struct ContentListView: View {
let pulls: PullRequests
let githubError: GitHubError?

var body: some View {
// TODO:
Text("ContentListView")
if let githubError {
List {
HStack {
Spacer()
Image(systemName: "exclamationmark.triangle")
.imageScale(.large)
Text(githubError.localizedDescription)
Spacer()
}
}
} else {
// TODO:

Check warning on line 19 in Pulse/ContentListView.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
Text("ContentListView")
}
}
}
26 changes: 16 additions & 10 deletions Pulse/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,24 @@
var body: some View {
VStack {
TabView(selection: $selection) {
// TODO:

Check warning on line 16 in Pulse/ContentView.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
ContentListView(pulls: pullRequest.settled)
.tabItem {
Text("Settled (\(pullRequest.settled.count))")
}
.tag(Tab.settled)
ContentListView(
pulls: pullRequest.settled,
githubError: pullRequest.error
)
.tabItem {
Text("Settled (\(pullRequest.settled.count))")
}
.tag(Tab.settled)
// TODO:

Check warning on line 25 in Pulse/ContentView.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
ContentListView(pulls: pullRequest.pending)
.tabItem {
Text("Pending (\(pullRequest.pending.count))")
}
.tag(Tab.pending)
ContentListView(
pulls: pullRequest.pending,
githubError: pullRequest.error
)
.tabItem {
Text("Pending (\(pullRequest.pending.count))")
}
.tag(Tab.pending)
}
.padding(.top, 5)
HStack {
Expand Down
9 changes: 6 additions & 3 deletions Pulse/PullRequestModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import SwiftUI

@MainActor
class PullRequestModel: ObservableObject {
// TODO:
@AppStorage("githubQuery") private var githubQuery = Constants.defaultGithubQuery
@Published var settled: PullRequests = []
@Published var pending: PullRequests = []
Expand All @@ -26,9 +25,13 @@ class PullRequestModel: ObservableObject {

self.settled = settled
self.pending = pending
error = nil
updatedAt = Date()
} catch let ghErr as GitHubError {
error = ghErr
} catch let githubError as GitHubError {
error = githubError
self.settled = []
self.pending = []
updatedAt = nil
} catch {
Logger.shared.error("failed to get pull requests: \(error)")
}
Expand Down
Loading