Skip to content

Commit c2be80a

Browse files
committed
remove properties model reference from Update User request
* We don't need the reference to the property model for an Update User request, and this reference has gone unused so far * We don't hydrate from the response as the response is not the full user, just the property that was updated. * The request still has a reference to the identity model it is operating on
1 parent 4bf6826 commit c2be80a

File tree

2 files changed

+1
-19
lines changed

2 files changed

+1
-19
lines changed

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

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,6 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
6161
if var updateRequestQueue = OneSignalUserDefaults.initShared().getSavedCodeableData(forKey: OS_PROPERTIES_EXECUTOR_UPDATE_REQUEST_QUEUE_KEY, defaultValue: []) as? [OSRequestUpdateProperties] {
6262
// Hook each uncached Request to the model in the store
6363
for (index, request) in updateRequestQueue.enumerated().reversed() {
64-
// 0. Hook up the properties model if its the current user's so it can hydrate
65-
if let propertiesModel = OneSignalUserManagerImpl.sharedInstance.propertiesModelStore.getModel(modelId: request.modelToUpdate.modelId) {
66-
request.modelToUpdate = propertiesModel
67-
}
6864
if let identityModel = OneSignalUserManagerImpl.sharedInstance.identityModelStore.getModel(modelId: request.identityModel.modelId) {
6965
// 1. The identity model exist in the store, set it to be the Request's models
7066
request.identityModel = identityModel
@@ -103,16 +99,10 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
10399
OneSignalLog.onesignalLog(.LL_VERBOSE, message: "OSPropertyOperationExecutor processDeltaQueue with queue: \(self.deltaQueue)")
104100
}
105101
for delta in self.deltaQueue {
106-
guard let model = delta.model as? OSPropertiesModel else {
107-
// Log error
108-
continue
109-
}
110-
111102
let request = OSRequestUpdateProperties(
112103
properties: [delta.property: delta.value],
113104
deltas: nil,
114105
refreshDeviceMetadata: false, // Sort this out.
115-
modelToUpdate: model,
116106
identityModel: OneSignalUserManagerImpl.sharedInstance.user.identityModel // TODO: Make sure this is ok
117107
)
118108
self.updateRequestQueue.append(request)
@@ -204,7 +194,6 @@ extension OSPropertyOperationExecutor {
204194
properties: [:],
205195
deltas: propertiesDeltas.jsonRepresentation(),
206196
refreshDeviceMetadata: refreshDeviceMetadata,
207-
modelToUpdate: propertiesModel,
208197
identityModel: identityModel)
209198

210199
if sendImmediately {

iOS_SDK/OneSignalSDK/OneSignalUser/Source/Requests/OSRequestUpdateProperties.swift

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ class OSRequestUpdateProperties: OneSignalRequest, OSUserRequest {
3434
return stringDescription
3535
}
3636

37-
// TODO: does updating properties even have a response in which we need to hydrate from? Then we can get rid of modelToUpdate
38-
// Yes we may, if we cleared local state
39-
var modelToUpdate: OSPropertiesModel
4037
var identityModel: OSIdentityModel
4138

4239
// TODO: Decide if addPushSubscriptionIdToAdditionalHeadersIfNeeded should block.
@@ -55,8 +52,7 @@ class OSRequestUpdateProperties: OneSignalRequest, OSUserRequest {
5552
}
5653
}
5754

58-
init(properties: [String: Any], deltas: [String: Any]?, refreshDeviceMetadata: Bool?, modelToUpdate: OSPropertiesModel, identityModel: OSIdentityModel) {
59-
self.modelToUpdate = modelToUpdate
55+
init(properties: [String: Any], deltas: [String: Any]?, refreshDeviceMetadata: Bool?, identityModel: OSIdentityModel) {
6056
self.identityModel = identityModel
6157
self.stringDescription = "<OSRequestUpdateProperties with properties: \(properties) deltas: \(String(describing: deltas)) refreshDeviceMetadata: \(String(describing: refreshDeviceMetadata))>"
6258
super.init()
@@ -79,7 +75,6 @@ class OSRequestUpdateProperties: OneSignalRequest, OSUserRequest {
7975
}
8076

8177
func encode(with coder: NSCoder) {
82-
coder.encode(modelToUpdate, forKey: "modelToUpdate")
8378
coder.encode(identityModel, forKey: "identityModel")
8479
coder.encode(parameters, forKey: "parameters")
8580
coder.encode(method.rawValue, forKey: "method") // Encodes as String
@@ -88,7 +83,6 @@ class OSRequestUpdateProperties: OneSignalRequest, OSUserRequest {
8883

8984
required init?(coder: NSCoder) {
9085
guard
91-
let modelToUpdate = coder.decodeObject(forKey: "modelToUpdate") as? OSPropertiesModel,
9286
let identityModel = coder.decodeObject(forKey: "identityModel") as? OSIdentityModel,
9387
let rawMethod = coder.decodeObject(forKey: "method") as? UInt32,
9488
let parameters = coder.decodeObject(forKey: "parameters") as? [String: Any],
@@ -97,7 +91,6 @@ class OSRequestUpdateProperties: OneSignalRequest, OSUserRequest {
9791
// Log error
9892
return nil
9993
}
100-
self.modelToUpdate = modelToUpdate
10194
self.identityModel = identityModel
10295
self.stringDescription = "<OSRequestUpdateProperties with parameters: \(parameters)>"
10396
super.init()

0 commit comments

Comments
 (0)