Refactor task usage and profile auto update

This commit is contained in:
世界
2023-09-22 11:32:51 +08:00
parent 390e063f20
commit 3374f8e727
49 changed files with 823 additions and 636 deletions
+5 -5
View File
@@ -12,17 +12,17 @@ open class ApplicationDelegate: NSObject, NSApplicationDelegate {
let launchedAsLogInItem =
event?.eventID == kAEOpenApplication &&
event?.paramDescriptor(forKeyword: keyAEPropData)?.enumCodeValue == keyAELaunchedAsLogInItem
if !launchedAsLogInItem || !SharedPreferences.showMenuBarExtra || !SharedPreferences.menuBarExtraInBackground {
if !launchedAsLogInItem || !SharedPreferences.showMenuBarExtra.getBlocking() || !SharedPreferences.menuBarExtraInBackground.getBlocking() {
NSApp.setActivationPolicy(.regular)
NSApp.activate(ignoringOtherApps: true)
} else {
NSApp.windows.first?.close()
}
Task.detached {
Task {
do {
try ProfileUpdateTask.setup()
try await ProfileUpdateTask.configure()
if launchedAsLogInItem {
if SharedPreferences.startedByUser {
if await SharedPreferences.startedByUser.get() {
if let profile = try await ExtensionProfile.load() {
try await profile.start()
}
@@ -35,7 +35,7 @@ open class ApplicationDelegate: NSObject, NSApplicationDelegate {
}
public func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool {
!SharedPreferences.menuBarExtraInBackground
!SharedPreferences.menuBarExtraInBackground.getBlocking()
}
public func applicationShouldHandleReopen(_: NSApplication, hasVisibleWindows flag: Bool) -> Bool {