Skip to content

Commit

Permalink
cache the calculated temporary unprotected domains property (#574)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414235014887631/1206018890798709/f
iOS PR:
macOS PR:
What kind of version bump will this require?: Major/Minor/Patch

Optional:

Tech Design URL:
CC:

Description:
Cache the calculated temporary unprotected domains property in ContentBlockerRulesUserScript.
  • Loading branch information
brindy authored Nov 24, 2023
1 parent 5b84e6d commit 88935a6
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,17 @@ open class ContentBlockerRulesUserScript: NSObject, UserScript {

public weak var delegate: ContentBlockerRulesUserScriptDelegate?

private var _temporaryUnprotectedDomainsCache = [String: [String]]()

var temporaryUnprotectedDomains: [String] {
if let domains = _temporaryUnprotectedDomainsCache[configuration.privacyConfiguration.identifier] {
return domains
}

let privacyConfiguration = configuration.privacyConfiguration
var temporaryUnprotectedDomains = privacyConfiguration.tempUnprotectedDomains.filter { !$0.trimmingWhitespace().isEmpty }
temporaryUnprotectedDomains.append(contentsOf: privacyConfiguration.exceptionsList(forFeature: .contentBlocking))
_temporaryUnprotectedDomainsCache = [configuration.privacyConfiguration.identifier: temporaryUnprotectedDomains]
return temporaryUnprotectedDomains
}

Expand Down

0 comments on commit 88935a6

Please sign in to comment.