Skip to content

Commit

Permalink
Maryia/Checking network status before initializing Pushwoosh
Browse files Browse the repository at this point in the history
  • Loading branch information
maryia-deriv-archive committed Feb 21, 2022
1 parent 925071d commit 0bbfe11
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion packages/core/src/Stores/pushwoosh-store.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { action } from 'mobx';
import { action, when } from 'mobx';
import { Pushwoosh } from 'web-push-notifications';
import { getAppId, urlForCurrentDomain } from '@deriv/shared';
import { getLanguage } from '@deriv/translations';
Expand All @@ -19,6 +19,18 @@ export default class PushwooshStore extends BaseStore {
*/
@action.bound
init = () => {
let reaction_id;
if (!this.root_store.common.is_network_online) {
reaction_id = when(
() => this.root_store.common.is_network_online,
() => {
this.init();
}
);
return;
}
// canceling the reaction once is_network_online becomes true for the first time:
reaction_id?.cancel();
if (!this.is_applicable && this.has_initialized) return;

this.push_woosh.push([
Expand Down

0 comments on commit 0bbfe11

Please sign in to comment.