File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ import OneSignalCore
35
35
public class OSOperationRepo : NSObject {
36
36
public static let sharedInstance = OSOperationRepo ( )
37
37
private var hasCalledStart = false
38
+ private var sessionCountDeltaQueued = false // used to know when to force-flush
38
39
39
40
// The Operation Repo dispatch queue, serial. This synchronizes access to `deltaQueue` and flushing behavior.
40
41
private let dispatchQueue = DispatchQueue ( label: " OneSignal.OSOperationRepo " , target: . global( ) )
@@ -107,14 +108,19 @@ public class OSOperationRepo: NSObject {
107
108
// TODO: We can make this method internal once there is no manual adding of a Delta except through stores.
108
109
This can happen when session data and purchase data use the model / store / listener infrastructure.
109
110
*/
110
- public func enqueueDelta( _ delta: OSDelta ) {
111
+ public func enqueueDelta( _ delta: OSDelta , flush : Bool = false ) {
111
112
guard !OneSignalConfigManager. shouldAwaitAppIdAndLogMissingPrivacyConsent ( forMethod: nil ) else {
112
113
return
113
114
}
114
115
start ( )
115
116
self . dispatchQueue. async {
116
117
OneSignalLog . onesignalLog ( . LL_VERBOSE, message: " OSOperationRepo enqueueDelta: \( delta) " )
117
118
self . deltaQueue. append ( delta)
119
+
120
+ if flush {
121
+ self . flushDeltaQueue ( )
122
+ }
123
+
118
124
// Persist the deltas (including new delta) to storage
119
125
OneSignalUserDefaults . initShared ( ) . saveCodeableData ( forKey: OS_OPERATION_REPO_DELTA_QUEUE_KEY, withValue: self . deltaQueue)
120
126
}
Original file line number Diff line number Diff line change @@ -583,7 +583,7 @@ extension OneSignalUserManagerImpl {
583
583
property: property. rawValue,
584
584
value: value
585
585
)
586
- OSOperationRepo . sharedInstance. enqueueDelta ( delta)
586
+ OSOperationRepo . sharedInstance. enqueueDelta ( delta, flush : true )
587
587
}
588
588
589
589
/// Time processors forward the session time to this method.
You can’t perform that action at this time.
0 commit comments