apps-sdk 1.0.154 → 1.0.155

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.0.154",
3
+ "version": "1.0.155",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -18,17 +18,45 @@ class PayWall extends React.Component {
18
18
  this.paywallJS = '';
19
19
  this.state = {
20
20
  htmlContent: null,
21
+ retryCount: 0
21
22
  };
23
+ this.maxRetries = 10;
24
+ this.retryInterval = 1000;
22
25
  }
23
26
 
24
27
  componentDidMount() {
28
+ const { type, keyword } = this.props;
25
29
  this.initPayWall();
30
+ this.getPayWallDataWithRetry(type, keyword);
26
31
  }
27
32
 
28
33
  initPayWall = async () => {
29
34
  await PayWallLogic.initializePayWall();
30
35
  }
31
36
 
37
+ getPayWallDataWithRetry = async (type, keyword) => {
38
+ if (this.state.retryCount >= this.maxRetries) {
39
+ console.log('Máximo número de reintentos alcanzado.');
40
+ return;
41
+ } else {
42
+ console.log('Reintentando obtener datos del paywall. Reintento número:', this.state.retryCount);
43
+ }
44
+
45
+ this.getPayWallData(type, keyword);
46
+
47
+ if (!this.paywallData.url) {
48
+ console.log('Esperando antes de reintentar...');
49
+ await new Promise(resolve => setTimeout(resolve, this.retryInterval));
50
+
51
+ this.setState(
52
+ prevState => ({ retryCount: prevState.retryCount + 1 }),
53
+ () => {
54
+ this.getPayWallDataWithRetry(type, keyword);
55
+ }
56
+ );
57
+ }
58
+ }
59
+
32
60
  getURL = (type, keyword) => {
33
61
  return config.PAYWALL_DATA[type][keyword].url || '';
34
62
  }
@@ -40,8 +68,10 @@ class PayWall extends React.Component {
40
68
 
41
69
  getPayWallData = (type, keyword) => {
42
70
  if (!config.PAYWALL_DATA[type] || !config.PAYWALL_DATA[type][keyword]) {
43
- Networking.sendEvent('ohter', 'no_paywall_data', {type: type, keyword: keyword, config: config.PAYWALL_DATA});
44
- console.log('No se encontraron datos para el paywall.');
71
+ if (keyword !== 'on_boarding') {
72
+ Networking.sendEvent('ohter', 'no_paywall_data', {type: type, keyword: keyword, config: config.PAYWALL_DATA});
73
+ console.log('No se encontraron datos para el paywall.');
74
+ }
45
75
  return;
46
76
  }
47
77
  this.paywallData = config.PAYWALL_DATA[type][keyword];
@@ -100,6 +130,9 @@ class PayWall extends React.Component {
100
130
 
101
131
  async componentDidUpdate(prevProps) {
102
132
  if (this.props.visible && !prevProps.visible && this.paywallData.url) {
133
+ const { type, keyword } = this.props;
134
+ await this.initPayWall();
135
+ await this.getPayWallDataWithRetry(type, keyword);
103
136
  await this.fetchAndModifyHTML();
104
137
  setTimeout(() => {
105
138
  Networking.sendEvent('scene', 'payment_card', {
@@ -208,9 +241,7 @@ class PayWall extends React.Component {
208
241
  render() {
209
242
  const { visible, onClose, type, keyword } = this.props;
210
243
  if (PayWallLogic.paywallJS === '' || Object.keys(this.paywallData).length === 0) {
211
- this.getPayWallData(type, keyword);
212
- // config.DEBUG_MODE && console.log('PayWallLogic.paywallJS:', PayWallLogic.paywallJS);
213
- // config.DEBUG_MODE && console.log('PayWallLogic.paywallJS type:', typeof PayWallLogic.paywallJS);
244
+ this.getPayWallDataWithRetry(type, keyword);
214
245
  }
215
246
 
216
247
  if (Object.keys(this.paywallData).length === 0 || !this.paywallData.url) {