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,8 +28,10 @@ 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()
}
}

View File

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

View File

@ -93,14 +93,14 @@ struct ThumbnailPickerView<ValueType: Hashable>: View {
extension ThumbnailPickerView {
struct Item<ValueType: Hashable>: Identifiable {
struct Item<Value: Hashable>: Identifiable {
let id = UUID()
let value: ValueType
let value: Value
let name: LocalizedStringKey
let description: LocalizedStringKey
let thumbnail: AnyView
init<ViewType: View>(value: ValueType, name: LocalizedStringKey, description: LocalizedStringKey, thumbnail: ViewType) {
init<ThumbnailView: View>(value: Value, name: LocalizedStringKey, description: LocalizedStringKey, thumbnail: ThumbnailView) {
self.value = value
self.name = name
self.description = description

View File

@ -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..<numberOfSteps) { index in
ForEach(0..<numberOfSteps, id: \.self) { index in
ZStack {
if currentStep > index {
Circle()