mirror of
https://github.com/maxgoedjen/secretive.git
synced 2025-04-04 06:37:07 +00:00
.
This commit is contained in:
parent
9b1f33b332
commit
5891e64c60
@ -7,7 +7,7 @@ public protocol UpdaterProtocol: ObservableObject {
|
||||
|
||||
}
|
||||
|
||||
@MainActor public class Updater: ObservableObject, UpdaterProtocol {
|
||||
public class Updater: ObservableObject, UpdaterProtocol {
|
||||
|
||||
@Published public var update: Release?
|
||||
|
||||
@ -30,10 +30,10 @@ public protocol UpdaterProtocol: ObservableObject {
|
||||
public func checkForUpdates() async {
|
||||
guard let (data, _) = try? await URLSession.shared.data(from: Constants.updateURL) else { return }
|
||||
guard let releases = try? JSONDecoder().decode([Release].self, from: data) else { return }
|
||||
evaluate(releases: releases)
|
||||
await evaluate(releases: releases)
|
||||
}
|
||||
|
||||
public func ignore(release: Release) {
|
||||
@MainActor public func ignore(release: Release) {
|
||||
guard !release.critical else { return }
|
||||
defaults.set(true, forKey: release.name)
|
||||
update = release
|
||||
@ -47,7 +47,7 @@ public protocol UpdaterProtocol: ObservableObject {
|
||||
|
||||
extension Updater {
|
||||
|
||||
func evaluate(releases: [Release]) {
|
||||
@MainActor func evaluate(releases: [Release]) {
|
||||
guard let release = releases
|
||||
.sorted()
|
||||
.reversed()
|
||||
|
@ -33,7 +33,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
|
||||
notifier.prompt()
|
||||
updateSink = updater.$update.sink { update in
|
||||
guard let update = update else { return }
|
||||
self.notifier.notify(update: update, ignore: self.updater.ignore(release:))
|
||||
Task {
|
||||
await MainActor.run {
|
||||
self.notifier.notify(update: update, ignore: self.updater.ignore(release:))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ class Notifier {
|
||||
notificationCenter.add(request, withCompletionHandler: nil)
|
||||
}
|
||||
|
||||
func notify(update: Release, ignore: ((Release) -> Void)?) {
|
||||
func notify(update: Release, ignore: (@MainActor (Release) -> Void)?) {
|
||||
notificationDelegate.release = update
|
||||
notificationDelegate.ignore = ignore
|
||||
let notificationCenter = UNUserNotificationCenter.current()
|
||||
@ -136,7 +136,7 @@ extension Notifier {
|
||||
class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
|
||||
|
||||
fileprivate var release: Release?
|
||||
fileprivate var ignore: ((Release) -> Void)?
|
||||
fileprivate var ignore: (@MainActor (Release) -> Void)?
|
||||
fileprivate var persistAuthentication: ((AnySecret, AnySecretStore, TimeInterval?) -> Void)?
|
||||
fileprivate var persistOptions: [String: TimeInterval] = [:]
|
||||
fileprivate var pendingPersistableStores: [String: AnySecretStore] = [:]
|
||||
@ -146,7 +146,7 @@ class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
|
||||
|
||||
}
|
||||
|
||||
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
@MainActor func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
|
||||
let category = response.notification.request.content.categoryIdentifier
|
||||
switch category {
|
||||
case Notifier.Constants.updateCategoryIdentitifier:
|
||||
@ -160,7 +160,7 @@ class NotificationDelegate: NSObject, UNUserNotificationCenterDelegate {
|
||||
completionHandler()
|
||||
}
|
||||
|
||||
func handleUpdateResponse(response: UNNotificationResponse) {
|
||||
@MainActor func handleUpdateResponse(response: UNNotificationResponse) {
|
||||
guard let update = release else { return }
|
||||
switch response.actionIdentifier {
|
||||
case Notifier.Constants.updateActionIdentitifier, UNNotificationDefaultActionIdentifier:
|
||||
|
@ -16,7 +16,11 @@ class AgentStatusChecker: ObservableObject, AgentStatusCheckerProtocol {
|
||||
}
|
||||
|
||||
func check() {
|
||||
running = instanceSecretAgentProcess != nil
|
||||
Task {
|
||||
await MainActor.run {
|
||||
running = instanceSecretAgentProcess != nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All processes, including ones from older versions, etc
|
||||
|
Loading…
Reference in New Issue
Block a user