Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wire up VPN error UI #2826

Merged
merged 6 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DuckDuckGo/NetworkProtectionStatusView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private struct NetworkProtectionErrorView: View {
.daxBodyRegular()
.foregroundColor(.primary)
}
.listRowBackground(Color(designSystemColor: .accent))
.listRowBackground(Color(designSystemColor: .surface))
}
}

Expand Down
19 changes: 19 additions & 0 deletions DuckDuckGo/NetworkProtectionStatusViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ final class NetworkProtectionStatusViewModel: ObservableObject {
setUpServerInfoPublishers()
setUpLocationPublishers()
setUpThroughputRefreshTimer()
setUpErrorPublishers()

// Prefetching this now for snappy load times on the locations screens
Task {
Expand Down Expand Up @@ -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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded the copy here for now so that it doesn't get accidentally translated, we'll come back to this once the error UI is complete and has final copy - for now I just want to get the UI itself in place so that we can use it.

}
.receive(on: DispatchQueue.main)
.assign(to: \.error, onWeaklyHeld: self)
.store(in: &cancellables)
}

private func setUpLocationPublishers() {
settings.selectedLocationPublisher
.receive(on: DispatchQueue.main)
Expand Down
Loading