fix: push subscription observers not firing #2330
Merged
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
Fix push subscription observers not firing by preventing manual removal of a PushSubscription which allows correct transfer of existing observers.
Details
replaceAllmethod. This will remove the current push subscription model and immediately add a new push subscription model. The Subscription Manager was removing the current push subscription and then adding a new push subscription that it manages. When the new one is added, the old one is removed and any observers are transferred over.replaceAll. There is no current usage where only [onModelRemoved] is called for a push subscription model.Motivation
Clients reported their push observers not firing in certain circumstances, and I was able to reproduce more generally as well.
Scope
PushSubscriptioninstance managed bySubscriptionManager, it will be removed by an expected immediate call to remove and add a newPushSubscriptioninstance.Testing
Unit testing
OPTIONAL - Explain unit tests added, if not clear in the code.
Manual testing
Android emulator API 33
onCreateand wait for the refresh-user call to complete. ToggleoptInandoptOutand see your observer fires before therefresh-userreturns and no longer fire after the call returns.Affected code checklist
Checklist
Overview
Testing
Final pass
This change is