Skip to content

Commit

Permalink
Add update button
Browse files Browse the repository at this point in the history
  • Loading branch information
winebarrel committed Nov 24, 2024
1 parent 770bbc1 commit 859eabc
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
24 changes: 21 additions & 3 deletions Pulse/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ struct ContentView: View {

@ObservedObject var pullRequest: PullRequestModel
@State private var selection = Tab.settled
@Binding var githubToken: String

var body: some View {
VStack {
Expand All @@ -27,8 +28,22 @@ struct ContentView: View {
}
.padding(.top, 5)
HStack {
Image(systemName: "clock.arrow.circlepath")
Text("00:00") // TODO:
Button {
Task {
let api = PullRequestAPI(githubToken)
await pullRequest.update(api)
}
} label: {
Image(systemName: "arrow.triangle.2.circlepath")
}

let label = if let updatedAt = pullRequest.updatedAt {
updatedAt.shortTime()
} else {
"-"
}

Text(label)
}
.padding(.bottom, 5)
}
Expand All @@ -37,5 +52,8 @@ struct ContentView: View {
}

#Preview {
ContentView(pullRequest: PullRequestModel())
ContentView(
pullRequest: PullRequestModel(),
githubToken: .constant("")
)
}
2 changes: 2 additions & 0 deletions Pulse/PullRequestModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import Foundation
@MainActor
class PullRequestModel: ObservableObject {
// TODO:

Check warning on line 5 in Pulse/PullRequestModel.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
@Published var updatedAt: Date?

func update(_ api: PullRequestAPI) async {
// TODO:

Check warning on line 9 in Pulse/PullRequestModel.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
updatedAt = Date()
}
}
2 changes: 1 addition & 1 deletion Pulse/PulseApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ struct PulseApp: App {
// TODO:

Check warning on line 24 in Pulse/PulseApp.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
// Notification.initialize()

let contentView = ContentView(pullRequest: pullRequest)
let contentView = ContentView(pullRequest: pullRequest, githubToken: $githubToken)
popover.contentViewController = NSHostingController(rootView: contentView)

scheduleUpdate()
Expand Down

0 comments on commit 859eabc

Please sign in to comment.