Skip to content

Commit e6e122b

Browse files
committed
Minor code rearrangement
1 parent ba9fb5c commit e6e122b

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

micSwitch/AppDelegate.swift

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ import Cocoa
1010

1111
@NSApplicationMain
1212
class AppDelegate: NSObject, NSApplicationDelegate {
13-
var preferences: PreferencesViewController?
14-
1513
func applicationDidFinishLaunching(_ aNotification: Notification) {
1614
if let statusButton = statusItem.button {
1715
statusButton.target = self
@@ -43,7 +41,17 @@ class AppDelegate: NSObject, NSApplicationDelegate {
4341
Audio.removeMicMuteListener(listenerId: muteListenerId)
4442
}
4543

46-
func showPreferences() {
44+
@objc func statusItemClicked(_ sender: Any?) {
45+
guard let event = NSApp.currentEvent else { return }
46+
switch event.type {
47+
case NSEvent.EventType.rightMouseUp:
48+
showPreferences()
49+
default:
50+
Audio.toggleMicMute()
51+
}
52+
}
53+
54+
private func showPreferences() {
4755
let preferences = self.preferences ?? PreferencesViewController.newInstance()
4856
self.preferences = preferences
4957

@@ -60,17 +68,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
6068
guard let button = statusItem.button else { return }
6169
button.image = NSImage(named: NSImage.Name(Audio.micMuted ? "micOff" : "micOn"))
6270
}
63-
64-
@objc func statusItemClicked(_ sender: Any?) {
65-
guard let event = NSApp.currentEvent else { return }
66-
switch event.type {
67-
case NSEvent.EventType.rightMouseUp:
68-
showPreferences()
69-
default:
70-
Audio.toggleMicMute()
71-
}
72-
}
73-
71+
72+
private var preferences: PreferencesViewController?
7473
private let statusItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
7574
private var muteListenerId: Int = -1
7675
}

0 commit comments

Comments
 (0)