Skip to content

Commit

Permalink
Use actor isolation for SubscriptionFeatureMappingCache (#1113)
Browse files Browse the repository at this point in the history
**Required**:

Task/Issue URL:
https://app.asana.com/0/414709148257752/1208887772407026/f
iOS PR: duckduckgo/iOS#3670
macOS PR: 
What kind of version bump will this require?: Hotfix


**Description**:
Use actor isolation for `SubscriptionFeatureMappingCache`

---
###### Internal references:
[Software Engineering
Expectations](https://app.asana.com/0/59792373528535/199064865822552)
[Technical Design
Template](https://app.asana.com/0/59792373528535/184709971311943)
  • Loading branch information
miasma13 authored Dec 4, 2024
1 parent 114cdbf commit a150770
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions Sources/Subscription/SubscriptionFeatureMappingCache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ public protocol SubscriptionFeatureMappingCache {
func subscriptionFeatures(for subscriptionIdentifier: String) async -> [Entitlement.ProductName]
}

public final class DefaultSubscriptionFeatureMappingCache: SubscriptionFeatureMappingCache {
public actor DefaultSubscriptionFeatureMappingCache: SubscriptionFeatureMappingCache {

private let subscriptionEndpointService: SubscriptionEndpointService
private let userDefaults: UserDefaults

private var subscriptionFeatureMapping: SubscriptionFeatureMapping?

public init(subscriptionEndpointService: SubscriptionEndpointService, userDefaults: UserDefaults) {
self.subscriptionEndpointService = subscriptionEndpointService
self.userDefaults = userDefaults
Expand Down Expand Up @@ -96,7 +94,7 @@ public final class DefaultSubscriptionFeatureMappingCache: SubscriptionFeatureMa

static private let subscriptionFeatureMappingKey = "com.duckduckgo.subscription.featuremapping"

dynamic var storedFeatureMapping: SubscriptionFeatureMapping? {
var storedFeatureMapping: SubscriptionFeatureMapping? {
get {
guard let data = userDefaults.data(forKey: Self.subscriptionFeatureMappingKey) else { return nil }
do {
Expand Down

0 comments on commit a150770

Please sign in to comment.