Skip to content

Commit

Permalink
fixup! Update executors to set offsets on consistency manager
Browse files Browse the repository at this point in the history
  • Loading branch information
rgomezp committed Oct 18, 2024
1 parent a983c0c commit e772819
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,13 @@ class OSPropertyOperationExecutor: OSOperationExecutor {
if let onesignalId = request.identityModel.onesignalId {
if let rywToken = response?["ryw_token"] as? String
{
OSConsistencyManager.shared.setRywToken(id: onesignalId, key: OSIamFetchOffsetKey.userUpdate, value: rywToken)
let rywDelay = response?["ryw_delay"] as? NSNumber

OSConsistencyManager.shared.setRywTokenAndDelay(
id: onesignalId,
key: OSIamFetchOffsetKey.userUpdate,
value: OSReadYourWriteData(rywToken: rywToken, rywDelay: rywDelay)
)
} else {
// handle a potential regression where ryw_token is no longer returned by API
OSConsistencyManager.shared.resolveConditionsWithID(id: OSIamFetchReadyCondition.CONDITIONID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,12 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor {
if let onesignalId = request.identityModel.onesignalId {
if let rywToken = response["ryw_token"] as? String
{
OSConsistencyManager.shared.setRywToken(id: onesignalId, key: OSIamFetchOffsetKey.subscriptionUpdate, value: rywToken)
let rywDelay = response["ryw_delay"] as? NSNumber
OSConsistencyManager.shared.setRywTokenAndDelay(
id: onesignalId,
key: OSIamFetchOffsetKey.subscriptionUpdate,
value: OSReadYourWriteData(rywToken: rywToken, rywDelay: rywDelay)
)
} else {
// handle a potential regression where ryw_token is no longer returned by API
OSConsistencyManager.shared.resolveConditionsWithID(id: OSIamFetchReadyCondition.CONDITIONID)
Expand Down Expand Up @@ -416,9 +421,14 @@ class OSSubscriptionOperationExecutor: OSOperationExecutor {
}

if let onesignalId = OneSignalUserManagerImpl.sharedInstance.onesignalId {
if let rywToken = response?["ryw_token"] as? String
if let rywToken = response?["ryw_token"] as? String
{
OSConsistencyManager.shared.setRywToken(id: onesignalId, key: OSIamFetchOffsetKey.subscriptionUpdate, value: rywToken)
let rywDelay = response?["ryw_delay"] as? NSNumber
OSConsistencyManager.shared.setRywTokenAndDelay(
id: onesignalId,
key: OSIamFetchOffsetKey.subscriptionUpdate,
value: OSReadYourWriteData(rywToken: rywToken, rywDelay: rywDelay)
)
} else {
// handle a potential regression where ryw_token is no longer returned by API
OSConsistencyManager.shared.resolveConditionsWithID(id: OSIamFetchReadyCondition.CONDITIONID)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,12 @@ extension OSUserExecutor {
if let onesignalId = request.identityModel.onesignalId {
if let rywToken = response["ryw_token"] as? String
{
OSConsistencyManager.shared.setRywToken(id: onesignalId, key: OSIamFetchOffsetKey.userCreate, value: rywToken)
let rywDelay = response["ryw_delay"] as? NSNumber
OSConsistencyManager.shared.setRywTokenAndDelay(
id: onesignalId,
key: OSIamFetchOffsetKey.userCreate,
value: OSReadYourWriteData(rywToken: rywToken, rywDelay: rywDelay)
)
} else {
// handle a potential regression where ryw_token is no longer returned by API
OSConsistencyManager.shared.resolveConditionsWithID(id: OSIamFetchReadyCondition.CONDITIONID)
Expand Down

0 comments on commit e772819

Please sign in to comment.