Skip to content

Commit

Permalink
Merge pull request #409 from Adamant-im/dev/trello.com/c/c3XR2OOx
Browse files Browse the repository at this point in the history
[trello.com/c/c3XR2OOx] feat: add new nodes to list if needed
  • Loading branch information
just-software-dev authored Dec 26, 2023
2 parents f8b8b2c + 5783199 commit ff2cc61
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 ff2cc61

Please sign in to comment.