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 update button #32

Merged
merged 1 commit into from
Nov 24, 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
24 changes: 21 additions & 3 deletions Pulse/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,18 @@

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

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)
PullRequestListView()
.tabItem {
Text("Settled (0)")
}
.tag(Tab.settled)
// TODO:

Check warning on line 22 in Pulse/ContentView.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
PullRequestListView()
.tabItem {
Text("Pending (0)")
Expand All @@ -27,8 +28,22 @@
}
.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 @@
}

#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 @@ -2,9 +2,11 @@

@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 @@ -21,10 +21,10 @@
}()

private func initialize() {
// 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 Expand Up @@ -52,7 +52,7 @@
MenuBarExtra {
RightClickMenuView()
} label: {
// TODO:

Check warning on line 55 in Pulse/PulseApp.swift

View workflow job for this annotation

GitHub Actions / Lint

Todo Violation: TODOs should be resolved (todo)
Image("check.black")
}.menuBarExtraAccess(isPresented: $isMenuPresented) { statusItem in
if !initialized {
Expand Down
Loading