Skip to content

Commit e37e40b

Browse files
committed
address review comments
* Rename `SupportedProperty.swift` to `OSPropertiesSupportedProperty.swift` and move to a higher-up folder in the user module * Simplify a piece of logic for combining properties by removing unnecessary intermediate step * Change a parameter type to an enum for more clarity and control
1 parent f1a986d commit e37e40b

File tree

4 files changed

+13
-14
lines changed

4 files changed

+13
-14
lines changed

iOS_SDK/OneSignalSDK/OneSignal.xcodeproj/project.pbxproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
3CE8CC582911B2B2000DB0D3 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CE8CC572911B2B2000DB0D3 /* SystemConfiguration.framework */; };
155155
3CE8CC5B29143F4B000DB0D3 /* NSDateFormatter+OneSignal.m in Sources */ = {isa = PBXBuildFile; fileRef = DE98772A2591655800DE07D5 /* NSDateFormatter+OneSignal.m */; };
156156
3CE9227A289FA88B001B1062 /* OSIdentityModelStoreListener.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CE92279289FA88B001B1062 /* OSIdentityModelStoreListener.swift */; };
157-
3CEE90A72BFE6ABD00B0FB5B /* SupportedProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CEE90A62BFE6ABD00B0FB5B /* SupportedProperty.swift */; };
157+
3CEE90A72BFE6ABD00B0FB5B /* OSPropertiesSupportedProperty.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CEE90A62BFE6ABD00B0FB5B /* OSPropertiesSupportedProperty.swift */; };
158158
3CEE90A92C000BD500B0FB5B /* OneSignalRequest+UnitTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CEE90A82C000BD500B0FB5B /* OneSignalRequest+UnitTests.swift */; };
159159
3CEE93422B7C4174008440BD /* OneSignalUserMocks.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3CC063DD2B6D7F2A002BB07F /* OneSignalUserMocks.framework */; };
160160
3CEE93432B7C4174008440BD /* OneSignalUserMocks.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3CC063DD2B6D7F2A002BB07F /* OneSignalUserMocks.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
@@ -1189,7 +1189,7 @@
11891189
3CE8CC552911B1E0000DB0D3 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/iOSSupport/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; };
11901190
3CE8CC572911B2B2000DB0D3 /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/System/Library/Frameworks/SystemConfiguration.framework; sourceTree = DEVELOPER_DIR; };
11911191
3CE92279289FA88B001B1062 /* OSIdentityModelStoreListener.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIdentityModelStoreListener.swift; sourceTree = "<group>"; };
1192-
3CEE90A62BFE6ABD00B0FB5B /* SupportedProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SupportedProperty.swift; sourceTree = "<group>"; };
1192+
3CEE90A62BFE6ABD00B0FB5B /* OSPropertiesSupportedProperty.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSPropertiesSupportedProperty.swift; sourceTree = "<group>"; };
11931193
3CEE90A82C000BD500B0FB5B /* OneSignalRequest+UnitTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "OneSignalRequest+UnitTests.swift"; sourceTree = "<group>"; };
11941194
3CF8629D28A183F900776CA4 /* OSIdentityModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSIdentityModel.swift; sourceTree = "<group>"; };
11951195
3CF8629F28A1964F00776CA4 /* OSPropertiesModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = OSPropertiesModel.swift; sourceTree = "<group>"; };
@@ -1922,7 +1922,6 @@
19221922
3C9AD6BA2B2284AB00BC1540 /* Executors */ = {
19231923
isa = PBXGroup;
19241924
children = (
1925-
3CEE90A52BFE6A7700B0FB5B /* Support */,
19261925
3C8E6E0028AC0BA10031E48A /* OSIdentityOperationExecutor.swift */,
19271926
3C8E6DFE28AB09AE0031E48A /* OSPropertyOperationExecutor.swift */,
19281927
3CE795FA28DBDCE700736BD4 /* OSSubscriptionOperationExecutor.swift */,
@@ -1997,7 +1996,7 @@
19971996
3CEE90A52BFE6A7700B0FB5B /* Support */ = {
19981997
isa = PBXGroup;
19991998
children = (
2000-
3CEE90A62BFE6ABD00B0FB5B /* SupportedProperty.swift */,
1999+
3CEE90A62BFE6ABD00B0FB5B /* OSPropertiesSupportedProperty.swift */,
20012000
);
20022001
path = Support;
20032002
sourceTree = "<group>";
@@ -2277,6 +2276,7 @@
22772276
DE69E1A8282ED8360090BB3D /* Source */ = {
22782277
isa = PBXGroup;
22792278
children = (
2279+
3CEE90A52BFE6A7700B0FB5B /* Support */,
22802280
3C9AD6BA2B2284AB00BC1540 /* Executors */,
22812281
3C9AD6BD2B22877600BC1540 /* Requests */,
22822282
DE69E1A9282ED8790090BB3D /* UnitTestApp-Bridging-Header.h */,
@@ -3948,7 +3948,7 @@
39483948
3C8E6E0128AC0BA10031E48A /* OSIdentityOperationExecutor.swift in Sources */,
39493949
3CF862A228A197D200776CA4 /* OSPropertiesModelStoreListener.swift in Sources */,
39503950
3C277D7E2BD76E0000857606 /* OSIdentityModelRepo.swift in Sources */,
3951-
3CEE90A72BFE6ABD00B0FB5B /* SupportedProperty.swift in Sources */,
3951+
3CEE90A72BFE6ABD00B0FB5B /* OSPropertiesSupportedProperty.swift in Sources */,
39523952
3C9AD6C12B22886600BC1540 /* OSRequestUpdateSubscription.swift in Sources */,
39533953
3C0EF49E28A1DBCB00E5434B /* OSUserInternalImpl.swift in Sources */,
39543954
3C8E6DFF28AB09AE0031E48A /* OSPropertyOperationExecutor.swift in Sources */,

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Executors/OSPropertyOperationExecutor.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,8 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
142142
OneSignalLog.onesignalLog(.LL_ERROR, message: "OSPropertyOperationExecutor.processDeltaQueue dropped: \(delta)")
143143
continue
144144
}
145-
var combinedSoFar: OSCombinedProperties? = combinedProperties[identityModel.modelId]
146-
combinedSoFar = self.combineProperties(existing: combinedSoFar, delta: delta)
147-
combinedProperties[identityModel.modelId] = combinedSoFar
145+
let combinedSoFar: OSCombinedProperties? = combinedProperties[identityModel.modelId]
146+
combinedProperties[identityModel.modelId] = self.combineProperties(existing: combinedSoFar, delta: delta)
148147
}
149148

150149
if combinedProperties.count > 1 {

iOS_SDK/OneSignalSDK/OneSignalUser/Source/OneSignalUserManagerImpl.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ public class OneSignalUserManagerImpl: NSObject, OneSignalUserManager {
511511
guard !OneSignalConfigManager.shouldAwaitAppIdAndLogMissingPrivacyConsent(forMethod: "sendPurchases") else {
512512
return
513513
}
514-
updatePropertiesDeltas(property: "purchases", value: purchases)
514+
updatePropertiesDeltas(property: .purchases, value: purchases)
515515
}
516516

517517
private func fireJwtExpired() {
@@ -540,7 +540,7 @@ extension OneSignalUserManagerImpl {
540540

541541
OSUserExecutor.executePendingRequests()
542542
OSOperationRepo.sharedInstance.paused = false
543-
updatePropertiesDeltas(property: "session_count", value: 1)
543+
updatePropertiesDeltas(property: .session_count, value: 1)
544544

545545
// Fetch the user's data if there is a onesignal_id
546546
if let onesignalId = onesignalId {
@@ -555,8 +555,8 @@ extension OneSignalUserManagerImpl {
555555
/// This method accepts properties updates that not driven by model changes.
556556
/// It enqueues an OSDelta to the Operation Repo.
557557
///
558-
/// - Parameter property:Expected inputs are `"session_time"`, `"session_count"`, and `"purchases"`.
559-
func updatePropertiesDeltas(property: String, value: Any) {
558+
/// - Parameter property:Expected inputs are `.session_time"`, `.session_count"`, and `.purchases"`.
559+
func updatePropertiesDeltas(property: OSPropertiesSupportedProperty, value: Any) {
560560
guard !OneSignalConfigManager.shouldAwaitAppIdAndLogMissingPrivacyConsent(forMethod: "updatePropertiesDeltas") else {
561561
return
562562
}
@@ -569,7 +569,7 @@ extension OneSignalUserManagerImpl {
569569
name: OS_UPDATE_PROPERTIES_DELTA,
570570
identityModelId: identityModel.modelId,
571571
model: propertiesModel,
572-
property: property,
572+
property: property.rawValue,
573573
value: value
574574
)
575575
OSOperationRepo.sharedInstance.enqueueDelta(delta)
@@ -581,7 +581,7 @@ extension OneSignalUserManagerImpl {
581581
guard !OneSignalConfigManager.shouldAwaitAppIdAndLogMissingPrivacyConsent(forMethod: "sendSessionTime") else {
582582
return
583583
}
584-
updatePropertiesDeltas(property: "session_time", value: sessionTime.intValue)
584+
updatePropertiesDeltas(property: .session_time, value: sessionTime.intValue)
585585
}
586586

587587
/**

0 commit comments

Comments
 (0)