@cardsjd/portal 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/BasePortal.js CHANGED
@@ -26,7 +26,7 @@ export class BasePortal {
26
26
 
27
27
  async getFriends() { }
28
28
 
29
- setupAds() { }
29
+ async setupAds() { }
30
30
 
31
31
  async loadInterstitialAd(_force) { }
32
32
 
@@ -111,7 +111,7 @@ export class FacebookPortal extends BasePortal {
111
111
 
112
112
  // ----- Ad methods -----
113
113
 
114
- setupAds() {
114
+ async setupAds() {
115
115
  console.log('FB_Ads.setup');
116
116
 
117
117
  if (typeof FBInstant === 'undefined' || !globalThis.FBInstant) {
@@ -20,6 +20,7 @@ export class NextGenAdMobPortal extends BasePortal {
20
20
  this.adProviderName = 'CapgoAdmob';
21
21
  this.isSetup = false;
22
22
  this.isSetupLoading = false;
23
+ this._setupPromise = null;
23
24
  this.isInterstitialAdReady = false;
24
25
  this._isRewardedAdLoaded = false;
25
26
  this._receivedReward = false;
@@ -116,18 +117,27 @@ export class NextGenAdMobPortal extends BasePortal {
116
117
  return;
117
118
  }
118
119
 
119
- if (this.isSetupLoading) {
120
- throw Error('Capgo AdMob setup is in progress already');
121
- }
120
+ if (!this._setupPromise) {
121
+ this._setupPromise = (async () => {
122
+ this.isSetupLoading = true;
122
123
 
123
- this.isSetupLoading = true;
124
+ try {
125
+ await this.updateConsentInfo();
126
+ } catch (error) {
127
+ console.error('Failed to update UMP consent info:', error);
128
+ } finally {
129
+ this.isSetupLoading = false;
130
+ }
131
+ })();
132
+ }
124
133
 
134
+ const setupPromise = this._setupPromise;
125
135
  try {
126
- await this.updateConsentInfo();
127
- } catch (error) {
128
- console.error('Failed to update UMP consent info:', error);
136
+ await setupPromise;
129
137
  } finally {
130
- this.isSetupLoading = false;
138
+ if (this._setupPromise === setupPromise) {
139
+ this._setupPromise = null;
140
+ }
131
141
  }
132
142
  }
133
143
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cardsjd/portal",
3
3
  "private": false,
4
- "version": "0.1.11",
4
+ "version": "0.1.13",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "publishConfig": {