Proposed fix for #2072 - EventGroup count variable should allowed to be zero
This would in turn fix: https://github.com/ionic-team/capacitor-plugins/issues/2072
This pull request addresses a bug introduced in commit e2cdf3538b9741c5ec394abb14516ceaf5e12d43 by @ItsChaceD on January 22nd, 2024.
The issue arises because the URL is opened from an activity instead of the plugin itself. This causes the unbindService method (called from handleOnPause in the plugin) to be invoked before the open method (called from the activity callback). This results in group.enter() being called before group.reset(). Consequently, when group.leave() is triggered from the TAB_HIDDEN navigation event, the browserEventListener.onBrowserEvent(BROWSER_FINISHED) event fires incorrectly when the app goes into the background.
This pull request fixes the bug by changing the count threshold from count <= 0 to count < 0, preventing the unintended firing of the BROWSER_FINISHED event.
While the order of calls remains unchanged, modifying the count threshold achieves the same outcome of ensuring group.reset() happens before group.leave().
Anyway we can get this merged?
@jcesarmobile Would it be possible to get this merged?