diff --git a/Passepartout/Library/Sources/CommonLibrary/Domain/Constants.swift b/Passepartout/Library/Sources/CommonLibrary/Domain/Constants.swift index f9424800..d4fcb913 100644 --- a/Passepartout/Library/Sources/CommonLibrary/Domain/Constants.swift +++ b/Passepartout/Library/Sources/CommonLibrary/Domain/Constants.swift @@ -99,6 +99,11 @@ public struct Constants: Decodable, Sendable { public let refreshInterval: TimeInterval public let tvExpirationMinutes: Int + + public func newTVExpirationDate() -> Date { + Date() + .addingTimeInterval(Double(tvExpirationMinutes) * 60.0) + } } public struct API: Decodable, Sendable { diff --git a/Passepartout/Library/Sources/UILibrary/Views/UI/TunnelToggleButton.swift b/Passepartout/Library/Sources/UILibrary/Views/UI/TunnelToggleButton.swift index 8d3493e5..20cfe104 100644 --- a/Passepartout/Library/Sources/UILibrary/Views/UI/TunnelToggleButton.swift +++ b/Passepartout/Library/Sources/UILibrary/Views/UI/TunnelToggleButton.swift @@ -107,14 +107,16 @@ private extension TunnelToggleButton { } } if canConnect && profile.isInteractive { - if iapManager.isEligible(for: .interactiveLogin) { + + // ineligible, suppress interactive login + if !iapManager.isEligible(for: .interactiveLogin) { + pp_log(.app, .notice, "Ineligible, suppress interactive login") + } else { pp_log(.app, .notice, "Present interactive login") interactiveManager.present(with: profile) { await perform(with: $0) } return - } else { - pp_log(.app, .notice, "Suppress interactive login, not eligible") } } await perform(with: profile) diff --git a/Passepartout/Shared/Shared+App.swift b/Passepartout/Shared/Shared+App.swift index 9985a44c..f82bd690 100644 --- a/Passepartout/Shared/Shared+App.swift +++ b/Passepartout/Shared/Shared+App.swift @@ -59,12 +59,12 @@ extension AppContext { // preprocess TV profiles if attributes.isAvailableForTV == true { - // if ineligible, set expiration date unless already set + // ineligible, set expiration date unless already set if !iap.isEligible(for: .appleTV), attributes.expirationDate == nil || attributes.isExpired { - - attributes.expirationDate = Date() - .addingTimeInterval(Double(Constants.shared.tunnel.tvExpirationMinutes) * 60.0) + let expirationDate = Constants.shared.tunnel.newTVExpirationDate() + pp_log(.app, .notice, "Ineligible, apply expiration date: \(expirationDate)") + attributes.expirationDate = expirationDate } else { attributes.expirationDate = nil } @@ -76,9 +76,9 @@ extension AppContext { willConnect: { iap, profile in var builder = profile.builder() - // suppress on-demand rules if not eligible + // ineligible, suppress on-demand rules if !iap.isEligible(for: .onDemand) { - pp_log(.app, .notice, "Suppress on-demand rules, not eligible") + pp_log(.app, .notice, "Ineligible, suppress on-demand rules") if let onDemandModuleIndex = builder.modules.firstIndex(where: { $0 is OnDemandModule }), let onDemandModule = builder.modules[onDemandModuleIndex] as? OnDemandModule {