Skip to content

Commit

Permalink
remove queue
Browse files Browse the repository at this point in the history
  • Loading branch information
SabrinaTardio committed Nov 12, 2024
1 parent 5829e29 commit 4ce4cba
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,23 @@ struct ExperimentsDataStore: ExperimentsDataStoring {
static let experimentsDataKey = "ExperimentsData"
}
private let localDataStoring: LocalDataStoring
private let queue = DispatchQueue(label: "com.experimentManager.queue")
private let decoder = JSONDecoder()
private let encoder = JSONEncoder()

Check failure on line 38 in Sources/BrowserServicesKit/PrivacyConfig/ExperimentsDataStore.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
init(localDataStoring: LocalDataStoring = UserDefaults.standard) {
self.localDataStoring = localDataStoring
encoder.dateEncodingStrategy = .secondsSince1970
decoder.dateDecodingStrategy = .secondsSince1970
}

Check failure on line 44 in Sources/BrowserServicesKit/PrivacyConfig/ExperimentsDataStore.swift

View workflow job for this annotation

GitHub Actions / Run SwiftLint

Lines should not have trailing whitespace (trailing_whitespace)
var experiments: Experiments? {
get {
queue.sync {
guard let savedData = localDataStoring.data(forKey: Constants.experimentsDataKey) else { return nil }
return try? decoder.decode(Experiments.self, from: savedData)
}
guard let savedData = localDataStoring.data(forKey: Constants.experimentsDataKey) else { return nil }
return try? decoder.decode(Experiments.self, from: savedData)
}
set {
queue.sync {
if let encodedData = try? encoder.encode(newValue) {
localDataStoring.set(encodedData, forKey: Constants.experimentsDataKey)
}
if let encodedData = try? encoder.encode(newValue) {
localDataStoring.set(encodedData, forKey: Constants.experimentsDataKey)
}
}
}
Expand Down

0 comments on commit 4ce4cba

Please sign in to comment.