Fix setPersistedBooleanProperty

Summary: WE should update the var in memory in setters. This line was somehow overlooked.

Reviewed By: dreamolight

Differential Revision: D51333425

fbshipit-source-id: cdf8bd5f0d97fe5a2b900c2d1ce0e198c65636c9
This commit is contained in:
Tao Xu
2023-11-15 14:25:03 -08:00
committed by Facebook GitHub Bot
parent fbb60846ad
commit 5c38779876
2 changed files with 15 additions and 0 deletions

View File

@@ -97,6 +97,7 @@ extension Settings {
func setPersistedBooleanProperty(_ property: PersistedBooleanValue, to value: Bool) {
validateConfiguration()
self[keyPath: property.backingKeyPath] = value
// swiftformat:disable:next redundantSelf
self.dataStore?.fb_setObject(value, forKey: property.persistenceKey.rawValue)
logIfSDKSettingsChanged()

View File

@@ -981,6 +981,20 @@ final class SettingsTests: XCTestCase {
// MARK: - Auto Log App Events Enabled
func testAutoLogAppEventsEnabledFromKeyPath() {
configureSettings()
settings.isAutoLogAppEventsEnabled = false
XCTAssertFalse(
settings.isAutoLogAppEventsEnabled,
"Auto logging should pick up the correct value from KeyPath"
)
settings.isAutoLogAppEventsEnabled = true
XCTAssertTrue(
settings.isAutoLogAppEventsEnabled,
"Auto logging should pick up the correct value from KeyPath when value changed"
)
}
func testAutoLogAppEventsEnabledFromPlist() {
bundle = TestBundle(infoDictionary: ["FacebookAutoLogAppEventsEnabled": false])
configureSettings()