Skip to content

Commit

Permalink
Update of the subscription entitlements API (#2486)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1206633753419160/f

Description:
Update of the subscription entitlements API
  • Loading branch information
miasma13 authored Feb 19, 2024
1 parent d1fc35a commit e12fca8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -9900,7 +9900,7 @@
repositoryURL = "https://github.com/DuckDuckGo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 108.1.0;
version = 109.0.0;
};
};
C14882EB27F211A000D59F0C /* XCRemoteSwiftPackageReference "SwiftSoup" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/DuckDuckGo/BrowserServicesKit",
"state" : {
"revision" : "ab03bde3e1817b267debe9858a08b3f0caf72dc3",
"version" : "108.1.0"
"revision" : "5ecf4fe56f334be6eaecb65f6d55632a6d53921c",
"version" : "109.0.0"
}
},
{
Expand Down Expand Up @@ -156,7 +156,7 @@
{
"identity" : "trackerradarkit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/TrackerRadarKit",
"location" : "https://github.com/duckduckgo/TrackerRadarKit.git",
"state" : {
"revision" : "a6b7ba151d9dc6684484f3785293875ec01cc1ff",
"version" : "1.2.2"
Expand Down
8 changes: 3 additions & 5 deletions DuckDuckGo/SettingsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ final class SettingsViewModel: ObservableObject {
@Published var shouldNavigateToDBP = false
@Published var shouldNavigateToITP = false

// Subscription Entitlement names: TBD
static let entitlementNames = ["dummy1", "dummy2", "dummy3"]

// Our View State
@Published private(set) var state: SettingsState

Expand Down Expand Up @@ -342,8 +339,9 @@ extension SettingsViewModel {
}

// Check for valid entitlements
let hasEntitlements = await AccountManager().hasEntitlement(for: Self.entitlementNames.first!)
self.state.subscription.hasActiveSubscription = hasEntitlements ? true : false
if case let .success(entitlements) = await AccountManager().fetchEntitlements() {
self.state.subscription.hasActiveSubscription = !entitlements.isEmpty
}

// Cache Subscription state
Self.cachedHasActiveSubscription = self.state.subscription.hasActiveSubscription
Expand Down
12 changes: 7 additions & 5 deletions DuckDuckGo/SubscriptionDebugViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@ final class SubscriptionDebugViewController: UITableViewController {
showAlert(title: "Not authenticated", message: "No authenticated user found! - Subscription not available")
return
}
for entitlementName in ["fake", "dummy1", "dummy2", "dummy3"] {
let result = await AccountManager().hasEntitlement(for: entitlementName)
let resultSummary = "Entitlement check for \(entitlementName): \(result)"
results.append(resultSummary)
print(resultSummary)
let entitlements: [AccountManager.Entitlement] = [.networkProtection, .dataBrokerProtection, .identityTheftRestoration]
for entitlement in entitlements {
if case let .success(result) = await AccountManager().hasEntitlement(for: entitlement) {
let resultSummary = "Entitlement check for \(entitlement.rawValue): \(result)"
results.append(resultSummary)
print(resultSummary)
}
}
showAlert(title: "Available Entitlements", message: results.joined(separator: "\n"))
}
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/DuckUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ let package = Package(
targets: ["DuckUI"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "108.1.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "109.0.0"),
],
targets: [
.target(
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/SyncUI/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ let package = Package(
],
dependencies: [
.package(path: "../DuckUI"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "108.1.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "109.0.0"),
.package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0")
],
targets: [
Expand Down
2 changes: 1 addition & 1 deletion LocalPackages/Waitlist/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
targets: ["Waitlist", "WaitlistMocks"])
],
dependencies: [
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "108.1.0"),
.package(url: "https://github.com/duckduckgo/BrowserServicesKit", exact: "109.0.0"),
.package(url: "https://github.com/duckduckgo/DesignResourcesKit", exact: "2.0.0")
],
targets: [
Expand Down

0 comments on commit e12fca8

Please sign in to comment.