You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reading Deltas and Requests from cache, connect to models
* Motivation: When initializing the delta queue and request queue, the executors need to hook up the Deltas' and Requests' models to the ones in the store, so that they can get the updated information needed to send the requests, and hydrate the correct models.
* When model stores, deltas, and requests are initialized from cache, they lose their references as they are new instances.
* To simplify uncaching, we maintain separate request queues for each request type in the executor
* Also needed to update some `let` properties to be `var`
Copy file name to clipboardExpand all lines: iOS_SDK/OneSignalSDK/OneSignalOSCore/Source/OSOperationExecutor.swift
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -27,15 +27,15 @@
27
27
28
28
import OneSignalCore
29
29
30
+
// TODO: Concrete executors drop OSDeltas and Requests when initializing from the cache, when they cannot be connected to their respective models anymore. Revisit this behavior of dropping.
// The model exists in the store, set it to be the Delta's model
45
+
delta.model = modelInStore
46
+
}else{
47
+
// The model does not exist, drop this Delta
48
+
deltaQueue.remove(at: index)
49
+
}
50
+
}
40
51
self.deltaQueue = deltaQueue
41
52
}else{
42
-
// log error
53
+
OneSignalLog.onesignalLog(.LL_ERROR, message:"OSIdentityOperationExecutor error encountered reading from cache for \(OS_IDENTITY_EXECUTOR_DELTA_QUEUE_KEY)")
// The model exists in the store, set it to be the Request's models
63
+
request.identityModel = identityModel
64
+
}elseif !request.prepareForExecution(){
65
+
// The models do not exist AND this request cannot be sent, drop this Request
66
+
addRequestQueue.remove(at: index)
67
+
}
68
+
}
69
+
self.addRequestQueue = addRequestQueue
70
+
}else{
71
+
OneSignalLog.onesignalLog(.LL_ERROR, message:"OSIdentityOperationExecutor error encountered reading from cache for \(OS_IDENTITY_EXECUTOR_ADD_REQUEST_QUEUE_KEY)")
// The model exists in the store, set it to be the Request's model
79
+
request.identityModel = identityModel
80
+
}elseif !request.prepareForExecution(){
81
+
// The model does not exist AND this request cannot be sent, drop this Request
82
+
removeRequestQueue.remove(at: index)
83
+
}
84
+
}
85
+
self.removeRequestQueue = removeRequestQueue
47
86
}else{
48
-
// log error
87
+
OneSignalLog.onesignalLog(.LL_ERROR, message:"OSIdentityOperationExecutor error encountered reading from cache for \(OS_IDENTITY_EXECUTOR_REMOVE_REQUEST_QUEUE_KEY)")
49
88
}
50
89
}
51
90
@@ -73,48 +112,47 @@ class OSIdentityOperationExecutor: OSOperationExecutor {
OneSignalUserDefaults.initShared().saveCodeableData(forKey: OS_IDENTITY_EXECUTOR_DELTA_QUEUE_KEY, withValue:self.deltaQueue) // This should be empty, can remove instead?
0 commit comments