From 210297a0ccd0e644897dbb67ab87be67e1e1b35d Mon Sep 17 00:00:00 2001 From: Max Goedjen Date: Thu, 22 Dec 2022 23:19:06 -0500 Subject: [PATCH] Fix bug where new secret wouldn't be selected --- Sources/Packages/Sources/SecretKit/SecretStoreList.swift | 7 +++---- Sources/Secretive/Views/ContentView.swift | 7 ++++++- Sources/Secretive/Views/SecretListItemView.swift | 3 ++- Sources/Secretive/Views/StoreListView.swift | 7 +++---- 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/Sources/Packages/Sources/SecretKit/SecretStoreList.swift b/Sources/Packages/Sources/SecretKit/SecretStoreList.swift index fbde248..1345d56 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 59dd3fc..461db2d 100644 --- a/Sources/Secretive/Views/ContentView.swift +++ b/Sources/Secretive/Views/ContentView.swift @@ -10,6 +10,7 @@ struct ContentView