fixed UI bug. Crash on hot plug/unplug Yubikey or similar

fix:Non-constant range: argument must be an integer literal
fix:Generic parameter 'ValueType' shadows generic parameter from outer scope with the same name; this is an error
fix:Converting non-sendable function value to '@Sendable (any FileHandleReader, any FileHandleWriter) async -> Bool' may introduce data races
This commit is contained in:
Dmitrii Taradai
2024-09-09 12:16:20 +03:00
parent 23b3297fee
commit a530a83e87
4 changed files with 14 additions and 9 deletions

View File

@@ -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 {