[Fix] Duplicate GET /user call on cold start when calling login with the same external_id #2015
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
One Line Summary
Omit making a GET /user call on cold start when calling login on the same external_id.
Details
We already refresh when the app is cold started, so this results in two GET calls back-to-back for apps that call login every time the app is opened the by the user. We are still refreshing the user if switch user happens.
Motivation
Optimize network calls is beneficial to the device and OneSignal's backend.
Scope
Only effects
OneSignal.login
, only omitting an extra get User call.Testing
Unit testing
Adding a test is out of scope for this PR, since there is no existing test infrastructure to test code in
OneSignalImp
. Also such code should be refactored out into a different class to make it more testable anyway.Manual testing
Test on an Android 14 emulator.
Before
After
Affected code checklist
Checklist
Overview
Testing
Final pass
This change is