Skip to content

Commit

Permalink
more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
streetturtle committed Dec 13, 2021
1 parent 69c36cc commit 2a654eb
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
31 changes: 26 additions & 5 deletions pullBar/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {

@Default(.refreshRate) var refreshRate

@Default(.githubUsername) var githubUsername
@Default(.githubToken) var githubToken

let ghClient = GitHubClient()
var statusBarItem: NSStatusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
let menu: NSMenu = NSMenu()
Expand Down Expand Up @@ -78,10 +81,20 @@ extension AppDelegate {
func refreshMenu() {
NSLog("Refreshing menu")
self.menu.removeAllItems()

if (githubUsername == "" || githubToken == "") {
addMenuFooterItems()
return
}


var assignedPulls: [Edge]? = []
var createdPulls: [Edge]? = []
var reviewRequestedPulls: [Edge]? = []




let group = DispatchGroup()

if showAssigned {
Expand Down Expand Up @@ -143,11 +156,7 @@ extension AppDelegate {
self.menu.addItem(.separator())
}

self.menu.addItem(withTitle: "Refresh", action: #selector(self.refreshMenu), keyEquivalent: "R")
self.menu.addItem(.separator())
self.menu.addItem(withTitle: "Preferences...", action: #selector(self.openPrefecencesWindow), keyEquivalent: ",")
self.menu.addItem(withTitle: "About PullBar", action: #selector(self.openAboutWindow), keyEquivalent: "")
self.menu.addItem(withTitle: "Quit", action: #selector(self.quit), keyEquivalent: "q")
self.addMenuFooterItems()
}

}
Expand Down Expand Up @@ -195,6 +204,14 @@ extension AppDelegate {
return issueItem
}

func addMenuFooterItems() {
self.menu.addItem(withTitle: "Refresh", action: #selector(self.refreshMenu), keyEquivalent: "R")
self.menu.addItem(.separator())
self.menu.addItem(withTitle: "Preferences...", action: #selector(self.openPrefecencesWindow), keyEquivalent: ",")
self.menu.addItem(withTitle: "About PullBar", action: #selector(self.openAboutWindow), keyEquivalent: "")
self.menu.addItem(withTitle: "Quit", action: #selector(self.quit), keyEquivalent: "q")
}

@objc
func openPrefecencesWindow(_: NSStatusBarButton?) {
NSLog("Open preferences window")
Expand All @@ -212,6 +229,8 @@ extension AppDelegate {
preferencesWindow.title = "Preferences"
preferencesWindow.contentView = NSHostingView(rootView: contentView)
preferencesWindow.makeKeyAndOrderFront(nil)
preferencesWindow.styleMask.remove(.resizable)

// allow the preference window can be focused automatically when opened
NSApplication.shared.activate(ignoringOtherApps: true)

Expand Down Expand Up @@ -239,6 +258,8 @@ extension AppDelegate {
aboutWindow.title = "About"
aboutWindow.contentView = NSHostingView(rootView: contentView)
aboutWindow.makeKeyAndOrderFront(nil)
aboutWindow.styleMask.remove(.resizable)

// allow the preference window can be focused automatically when opened
NSApplication.shared.activate(ignoringOtherApps: true)

Expand Down
3 changes: 3 additions & 0 deletions pullBar/GitHub/GitHubClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public class GitHubClient {
}

func getReviewRequestedPulls(completion:@escaping (([Edge]) -> Void)) -> Void {
if (githubUsername == "" || githubToken == "") {
completion([Edge]())
}

let headers: HTTPHeaders = [
.authorization(username: githubUsername, password: githubToken),
Expand Down
2 changes: 1 addition & 1 deletion pullBar/Views/AboutView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct AboutView: View {
VStack {
Image(nsImage: NSImage(named: "AppIcon")!)
Text("PullBar").font(.title)
Text("By Pavel Makhov").font(.caption)
Text("by Pavel Makhov").font(.caption)
Text("Version " + currentVersion).font(.footnote)
Divider()
Link("PullBar on GitHub", destination: URL(string: "https://github.com/menubar-apps-for-devs/PullBar")!)
Expand Down

0 comments on commit 2a654eb

Please sign in to comment.