Skip to content

Commit ff2cc61

Browse files
Merge pull request #409 from Adamant-im/dev/trello.com/c/c3XR2OOx
[trello.com/c/c3XR2OOx] feat: add new nodes to list if needed
2 parents f8b8b2c + 5783199 commit ff2cc61

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Adamant/Services/NodesStorage.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,14 @@ final class NodesStorage: NodesStorageProtocol {
9292
init(securedStore: SecuredStore) {
9393
self.securedStore = securedStore
9494

95+
var nodes = securedStore.get(StoreKey.NodesStorage.nodes) ?? Self.defaultItems
96+
let nodesToAdd = Self.defaultItems.filter { defaultNode in
97+
!nodes.contains { $0.node.host == defaultNode.node.host }
98+
}
99+
nodes.append(contentsOf: nodesToAdd)
100+
95101
_items = .init(wrappedValue: .init(
96-
wrappedValue: securedStore.get(StoreKey.NodesStorage.nodes) ?? Self.defaultItems
102+
wrappedValue: nodes
97103
))
98104

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

0 commit comments

Comments
 (0)