Skip to content

Commit

Permalink
[trello.com/c/c3XR2OOx] feat: add new nodes to list if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
StanislavDevIOS committed Dec 25, 2023
1 parent 1dbdfe2 commit 5783199
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Adamant/Services/NodesStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ final class NodesStorage: NodesStorageProtocol {
init(securedStore: SecuredStore) {
self.securedStore = securedStore

var nodes = securedStore.get(StoreKey.NodesStorage.nodes) ?? Self.defaultItems
let nodesToAdd = Self.defaultItems.filter { defaultNode in
!nodes.contains { $0.node.host == defaultNode.node.host }
}
nodes.append(contentsOf: nodesToAdd)

_items = .init(wrappedValue: .init(
wrappedValue: securedStore.get(StoreKey.NodesStorage.nodes) ?? Self.defaultItems
wrappedValue: nodes
))

subscription = items.removeDuplicates().sink { [weak self] in
Expand Down

0 comments on commit 5783199

Please sign in to comment.