mirror of
https://github.com/Toxblh/MTMR.git
synced 2026-01-11 09:28:38 +00:00
little cleanup
This commit is contained in:
parent
2635e2611f
commit
820853d300
@ -46,17 +46,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func updateIsBlockedApp() {
|
@objc func updateIsBlockedApp() {
|
||||||
var blacklistAppIdentifiers: [String] = []
|
if let frontmostAppId = TouchBarController.shared.frontmostApplicationIdentifier {
|
||||||
if let blackListed = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") {
|
let blacklistAppIdentifiers = UserDefaults.standard.stringArray(forKey: "com.toxblh.mtmr.blackListedApps") ?? []
|
||||||
blacklistAppIdentifiers = blackListed
|
isBlockedApp = blacklistAppIdentifiers.firstIndex(of: frontmostAppId) != nil
|
||||||
}
|
|
||||||
var frontmostApplicationIdentifier: String? {
|
|
||||||
guard let frontmostId = NSWorkspace.shared.frontmostApplication?.bundleIdentifier else { return nil }
|
|
||||||
return frontmostId
|
|
||||||
}
|
|
||||||
|
|
||||||
if frontmostApplicationIdentifier != nil {
|
|
||||||
isBlockedApp = blacklistAppIdentifiers.firstIndex(of: frontmostApplicationIdentifier!) != nil
|
|
||||||
} else {
|
} else {
|
||||||
isBlockedApp = false
|
isBlockedApp = false
|
||||||
}
|
}
|
||||||
@ -79,12 +71,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc func toggleBlackListedApp(_: Any?) {
|
@objc func toggleBlackListedApp(_: Any?) {
|
||||||
let appIdentifier = TouchBarController.shared.frontmostApplicationIdentifier
|
if let appIdentifier = TouchBarController.shared.frontmostApplicationIdentifier {
|
||||||
if appIdentifier != nil {
|
if let index = TouchBarController.shared.blacklistAppIdentifiers.firstIndex(of: appIdentifier) {
|
||||||
if let index = TouchBarController.shared.blacklistAppIdentifiers.firstIndex(of: appIdentifier!) {
|
|
||||||
TouchBarController.shared.blacklistAppIdentifiers.remove(at: index)
|
TouchBarController.shared.blacklistAppIdentifiers.remove(at: index)
|
||||||
} else {
|
} else {
|
||||||
TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier!)
|
TouchBarController.shared.blacklistAppIdentifiers.append(appIdentifier)
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDefaults.standard.set(TouchBarController.shared.blacklistAppIdentifiers, forKey: "com.toxblh.mtmr.blackListedApps")
|
UserDefaults.standard.set(TouchBarController.shared.blacklistAppIdentifiers, forKey: "com.toxblh.mtmr.blackListedApps")
|
||||||
|
|||||||
@ -101,8 +101,7 @@ class TouchBarController: NSObject, NSTouchBarDelegate {
|
|||||||
|
|
||||||
var blacklistAppIdentifiers: [String] = []
|
var blacklistAppIdentifiers: [String] = []
|
||||||
var frontmostApplicationIdentifier: String? {
|
var frontmostApplicationIdentifier: String? {
|
||||||
guard let frontmostId = NSWorkspace.shared.frontmostApplication?.bundleIdentifier else { return nil }
|
return NSWorkspace.shared.frontmostApplication?.bundleIdentifier
|
||||||
return frontmostId
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private override init() {
|
private override init() {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user