Skip to content

Commit

Permalink
Hides the website exclusion view in VPN status when the feature is di…
Browse files Browse the repository at this point in the history
…sabled
  • Loading branch information
diegoreymendez committed Jan 17, 2025
1 parent 9dea861 commit 4398b91
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ extension NetworkProtectionStatusView {
onboardingStatusPublisher: onboardingStatusPublisher,
statusReporter: statusReporter,
vpnSettings: .init(defaults: userDefaults),
proxySettings: .init(defaults: userDefaults),
locationFormatter: locationFormatter,
uiActionHandler: uiActionHandler)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,33 +81,35 @@ public struct TunnelControllerView: View {
}
}

SiteTroubleshootingView()
.padding(.top, 5)

if #available(macOS 14.0, *),
tipsModel.canShowDomainExclusionsTip {

TipView(tipsModel.domainExclusionsTip)
.tipImageSize(VPNTipsModel.imageSize)
.tipBackground(Color(.tipBackground))
.padding(.horizontal, 9)
.padding(.vertical, 6)
.onAppear {
tipsModel.handleDomainExclusionsTipShown()
}
.task {
var previousStatus = tipsModel.domainExclusionsTip.status

for await status in tipsModel.domainExclusionsTip.statusUpdates {
if case .invalidated(let reason) = status {
if case .available = previousStatus {
tipsModel.handleDomainExclusionTipInvalidated(reason)
if model.exclusionsFeatureEnabled {
SiteTroubleshootingView()
.padding(.top, 5)

if #available(macOS 14.0, *),
tipsModel.canShowDomainExclusionsTip {

TipView(tipsModel.domainExclusionsTip)
.tipImageSize(VPNTipsModel.imageSize)
.tipBackground(Color(.tipBackground))
.padding(.horizontal, 9)
.padding(.vertical, 6)
.onAppear {
tipsModel.handleDomainExclusionsTipShown()
}
.task {
var previousStatus = tipsModel.domainExclusionsTip.status

for await status in tipsModel.domainExclusionsTip.statusUpdates {
if case .invalidated(let reason) = status {
if case .available = previousStatus {
tipsModel.handleDomainExclusionTipInvalidated(reason)
}
}
}

previousStatus = status
previousStatus = status
}
}
}
}
}

Divider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import Combine
import Foundation
import NetworkProtection
import NetworkProtectionProxy
import SwiftUI
import TipKit

Expand Down Expand Up @@ -47,6 +48,10 @@ public final class TunnelControllerViewModel: ObservableObject {
}
}

public var exclusionsFeatureEnabled: Bool {
proxySettings.proxyAvailable
}

/// The type of extension that's being used for NetP
///
@Published
Expand All @@ -67,6 +72,7 @@ public final class TunnelControllerViewModel: ObservableObject {
private let statusReporter: NetworkProtectionStatusReporter

private let vpnSettings: VPNSettings
private let proxySettings: TransparentProxySettings
private let locationFormatter: VPNLocationFormatting

private static let byteCountFormatter: ByteCountFormatter = {
Expand All @@ -92,6 +98,7 @@ public final class TunnelControllerViewModel: ObservableObject {
statusReporter: NetworkProtectionStatusReporter,
runLoopMode: RunLoop.Mode? = nil,
vpnSettings: VPNSettings,
proxySettings: TransparentProxySettings,
locationFormatter: VPNLocationFormatting,
uiActionHandler: VPNUIActionHandling) {

Expand All @@ -100,6 +107,7 @@ public final class TunnelControllerViewModel: ObservableObject {
self.statusReporter = statusReporter
self.runLoopMode = runLoopMode
self.vpnSettings = vpnSettings
self.proxySettings = proxySettings
self.locationFormatter = locationFormatter
self.uiActionHandler = uiActionHandler

Expand Down

0 comments on commit 4398b91

Please sign in to comment.