diff --git a/Sources/Packages/Sources/SecretKit/SecretStoreList.swift b/Sources/Packages/Sources/SecretKit/SecretStoreList.swift index fbde248a..1345d56b 100644 --- a/Sources/Packages/Sources/SecretKit/SecretStoreList.swift +++ b/Sources/Packages/Sources/SecretKit/SecretStoreList.swift @@ -8,7 +8,7 @@ public class SecretStoreList: ObservableObject { @Published public var stores: [AnySecretStore] = [] /// A modifiable store, if one is available. @Published public var modifiableStore: AnySecretStoreModifiable? - private var sinks: [AnyCancellable] = [] + private var cancellables: Set = [] /// Initializes a SecretStoreList. public init() { @@ -41,10 +41,9 @@ extension SecretStoreList { private func addInternal(store: AnySecretStore) { stores.append(store) - let sink = store.objectWillChange.sink { + store.objectWillChange.sink { self.objectWillChange.send() - } - sinks.append(sink) + }.store(in: &cancellables) } } diff --git a/Sources/Secretive/Views/ContentView.swift b/Sources/Secretive/Views/ContentView.swift index 59dd3fc6..461db2d7 100644 --- a/Sources/Secretive/Views/ContentView.swift +++ b/Sources/Secretive/Views/ContentView.swift @@ -10,6 +10,7 @@ struct ContentView: View { Spacer() Button("Delete", action: delete) .disabled(confirm != secret.name) - .keyboardShortcut(.delete) Button("Don't Delete") { dismissalBlock(false) } diff --git a/Sources/Secretive/Views/SecretListItemView.swift b/Sources/Secretive/Views/SecretListItemView.swift index e70c47d8..958d905a 100644 --- a/Sources/Secretive/Views/SecretListItemView.swift +++ b/Sources/Secretive/Views/SecretListItemView.swift @@ -29,7 +29,8 @@ struct SecretListItemView: View { } else { Text(secret.name) } - }.contextMenu { + } + .contextMenu { if store is AnySecretStoreModifiable { Button(action: { isRenaming = true }) { Text("Rename") diff --git a/Sources/Secretive/Views/StoreListView.swift b/Sources/Secretive/Views/StoreListView.swift index 84d3afc7..c2b64e23 100644 --- a/Sources/Secretive/Views/StoreListView.swift +++ b/Sources/Secretive/Views/StoreListView.swift @@ -1,12 +1,11 @@ import SwiftUI +import Combine import SecretKit struct StoreListView: View { - @Binding var showingCreation: Bool + @Binding var activeSecret: AnySecret.ID? - @State private var activeSecret: AnySecret.ID? - @EnvironmentObject private var storeList: SecretStoreList private func secretDeleted(secret: AnySecret) { @@ -14,7 +13,7 @@ struct StoreListView: View { } private func secretRenamed(secret: AnySecret) { - activeSecret = nextDefaultSecret + activeSecret = secret.id } var body: some View {