From d0eb8aa2f344e20a1f4d1dfc398c5c339dcf7f77 Mon Sep 17 00:00:00 2001 From: Sam Symons Date: Thu, 9 May 2024 09:23:36 -0700 Subject: [PATCH] Wire up VPN error UI (#2826) Task/Issue URL: https://app.asana.com/0/414235014887631/1207198886354136/f Tech Design URL: CC: Description: This PR re-enables the VPN error UI. This is done for internal users only. --- DuckDuckGo/NetworkProtectionStatusView.swift | 2 +- .../NetworkProtectionStatusViewModel.swift | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/DuckDuckGo/NetworkProtectionStatusView.swift b/DuckDuckGo/NetworkProtectionStatusView.swift index 953881fd00..ffd1ace366 100644 --- a/DuckDuckGo/NetworkProtectionStatusView.swift +++ b/DuckDuckGo/NetworkProtectionStatusView.swift @@ -248,7 +248,7 @@ private struct NetworkProtectionErrorView: View { .daxBodyRegular() .foregroundColor(.primary) } - .listRowBackground(Color(designSystemColor: .accent)) + .listRowBackground(Color(designSystemColor: .surface)) } } diff --git a/DuckDuckGo/NetworkProtectionStatusViewModel.swift b/DuckDuckGo/NetworkProtectionStatusViewModel.swift index 904eb97fc0..0d317bbdcb 100644 --- a/DuckDuckGo/NetworkProtectionStatusViewModel.swift +++ b/DuckDuckGo/NetworkProtectionStatusViewModel.swift @@ -166,6 +166,7 @@ final class NetworkProtectionStatusViewModel: ObservableObject { setUpServerInfoPublishers() setUpLocationPublishers() setUpThroughputRefreshTimer() + setUpErrorPublishers() // Prefetching this now for snappy load times on the locations screens Task { @@ -288,6 +289,24 @@ final class NetworkProtectionStatusViewModel: ObservableObject { .store(in: &cancellables) } + private func setUpErrorPublishers() { + guard AppDependencyProvider.shared.internalUserDecider.isInternalUser else { + return + } + + errorObserver.publisher + .map { errorMessage in + guard let errorMessage else { + return nil + } + + return ErrorItem(title: "Failed to Connect", message: errorMessage) + } + .receive(on: DispatchQueue.main) + .assign(to: \.error, onWeaklyHeld: self) + .store(in: &cancellables) + } + private func setUpLocationPublishers() { settings.selectedLocationPublisher .receive(on: DispatchQueue.main)