From 5783199604f0ee78b4621b1ff4dc45a8fe35a060 Mon Sep 17 00:00:00 2001 From: StanislavDevIOS Date: Mon, 25 Dec 2023 14:45:03 +0200 Subject: [PATCH] [trello.com/c/c3XR2OOx] feat: add new nodes to list if needed --- Adamant/Services/NodesStorage.swift | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Adamant/Services/NodesStorage.swift b/Adamant/Services/NodesStorage.swift index c2566a59c..4b1c63196 100644 --- a/Adamant/Services/NodesStorage.swift +++ b/Adamant/Services/NodesStorage.swift @@ -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