Skip to content

Commit

Permalink
Allow hiding the menu bar icon
Browse files Browse the repository at this point in the history
closes #40
  • Loading branch information
grishka committed Sep 26, 2023
1 parent 0c1a158 commit a43d812
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions NearDrop/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
statusItem=NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
statusItem?.button?.image=NSImage(named: "MenuBarIcon")
statusItem?.menu=menu
statusItem?.behavior = .removalAllowed

let nc=UNUserNotificationCenter.current()
nc.requestAuthorization(options: [.alert, .sound]) { granted, err in
Expand All @@ -39,6 +40,11 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
NearbyConnectionManager.shared.mainAppDelegate=self
NearbyConnectionManager.shared.becomeVisible()
}

func applicationShouldHandleReopen(_ sender: NSApplication, hasVisibleWindows flag: Bool) -> Bool {
statusItem?.isVisible=true
return true
}

func applicationWillTerminate(_ aNotification: Notification) {
UNUserNotificationCenter.current().removeAllDeliveredNotifications()
Expand Down
2 changes: 1 addition & 1 deletion NearbyShare/InboundNearbyConnection.swift
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ class InboundNearbyConnection: NearbyConnection{
currentState = .receivingFiles
try sendTransferSetupFrame(frame)
}catch{
print("Error \(error)")
lastError=error
protocolError()
}
}
Expand Down

0 comments on commit a43d812

Please sign in to comment.