diff --git a/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift b/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift index bf5a74d..1caf95d 100644 --- a/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift +++ b/Sources/Packages/Sources/SecretKit/Erasers/AnySecretStore.swift @@ -2,7 +2,7 @@ import Foundation import Combine /// Type eraser for SecretStore. -public class AnySecretStore: SecretStore { +public class AnySecretStore: SecretStore, ObservableObject { let base: Any private let _isAvailable: () -> Bool @@ -28,9 +28,11 @@ public class AnySecretStore: SecretStore { _existingPersistedAuthenticationContext = { secretStore.existingPersistedAuthenticationContext(secret: $0.base as! SecretStoreType.SecretType) } _persistAuthentication = { try secretStore.persistAuthentication(secret: $0.base as! SecretStoreType.SecretType, forDuration: $1) } _reloadSecrets = { secretStore.reloadSecrets() } - sink = secretStore.objectWillChange.sink { _ in - self.objectWillChange.send() - } + sink = secretStore.objectWillChange + .receive(on: DispatchQueue.main) // Ensure updates are received on the main thread + .sink { [weak self] _ in + self?.objectWillChange.send() + } } public var isAvailable: Bool { diff --git a/Sources/SecretAgent/AppDelegate.swift b/Sources/SecretAgent/AppDelegate.swift index ab6a3cd..82ef8ed 100644 --- a/Sources/SecretAgent/AppDelegate.swift +++ b/Sources/SecretAgent/AppDelegate.swift @@ -32,7 +32,10 @@ class AppDelegate: NSObject, NSApplicationDelegate { func applicationDidFinishLaunching(_ aNotification: Notification) { logger.debug("SecretAgent finished launching") DispatchQueue.main.async { - self.socketController.handler = self.agent.handle(reader:writer:) + self.socketController.handler = { [weak self] reader, writer in + guard let self = self else { return false } + return await self.agent.handle(reader: reader, writer: writer) + } } NotificationCenter.default.addObserver(forName: .secretStoreReloaded, object: nil, queue: .main) { [self] _ in try? publicKeyFileStoreController.generatePublicKeys(for: storeList.allSecrets, clear: true) diff --git a/Sources/Secretive/Views/CreateSecretView.swift b/Sources/Secretive/Views/CreateSecretView.swift index accd8be..8181989 100644 --- a/Sources/Secretive/Views/CreateSecretView.swift +++ b/Sources/Secretive/Views/CreateSecretView.swift @@ -93,14 +93,14 @@ struct ThumbnailPickerView: View { extension ThumbnailPickerView { - struct Item: Identifiable { + struct Item: Identifiable { let id = UUID() - let value: ValueType + let value: Value let name: LocalizedStringKey let description: LocalizedStringKey let thumbnail: AnyView - init(value: ValueType, name: LocalizedStringKey, description: LocalizedStringKey, thumbnail: ViewType) { + init(value: Value, name: LocalizedStringKey, description: LocalizedStringKey, thumbnail: ThumbnailView) { self.value = value self.name = name self.description = description diff --git a/Sources/Secretive/Views/SetupView.swift b/Sources/Secretive/Views/SetupView.swift index ffd142c..0ca2a4d 100644 --- a/Sources/Secretive/Views/SetupView.swift +++ b/Sources/Secretive/Views/SetupView.swift @@ -55,7 +55,7 @@ struct StepView: View { .foregroundColor(.green) .frame(width: max(0, ((width - (Constants.padding * 2)) / Double(numberOfSteps - 1)) * Double(currentStep) - (Constants.circleWidth / 2)), height: 5) HStack { - ForEach(0.. index { Circle()