apps-sdk 1.0.150 → 1.0.152

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.150",
3
+ "version": "1.0.152",
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 = 50;
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,6 +68,7 @@ class PayWall extends React.Component {
40
68
 
41
69
  getPayWallData = (type, keyword) => {
42
70
  if (!config.PAYWALL_DATA[type] || !config.PAYWALL_DATA[type][keyword]) {
71
+ Networking.sendEvent('ohter', 'no_paywall_data', {type: type, keyword: keyword, config: config.PAYWALL_DATA});
43
72
  console.log('No se encontraron datos para el paywall.');
44
73
  return;
45
74
  }
@@ -99,6 +128,9 @@ class PayWall extends React.Component {
99
128
 
100
129
  async componentDidUpdate(prevProps) {
101
130
  if (this.props.visible && !prevProps.visible && this.paywallData.url) {
131
+ const { type, keyword } = this.props;
132
+ await this.initPayWall();
133
+ await this.getPayWallDataWithRetry(type, keyword);
102
134
  await this.fetchAndModifyHTML();
103
135
  setTimeout(() => {
104
136
  Networking.sendEvent('scene', 'payment_card', {
@@ -200,15 +232,13 @@ class PayWall extends React.Component {
200
232
  render() {
201
233
  const { visible, onClose, type, keyword } = this.props;
202
234
  if (PayWallLogic.paywallJS === '' || Object.keys(this.paywallData).length === 0) {
203
- this.getPayWallData(type, keyword);
204
- // config.DEBUG_MODE && console.log('PayWallLogic.paywallJS:', PayWallLogic.paywallJS);
205
- // config.DEBUG_MODE && console.log('PayWallLogic.paywallJS type:', typeof PayWallLogic.paywallJS);
235
+ this.getPayWallDataWithRetry(type, keyword);
206
236
  }
207
237
 
208
238
  if (!this.paywallData.url) {
209
- config.DEBUG_MODE && console.log('PayWallLogic: paywallData no tiene url para este type / keyword -> ' + type + ' / ' + keyword);
210
- return null;
211
- }
239
+ config.DEBUG_MODE && console.log('PayWallLogic: paywallData no tiene url para este type / keyword -> ' + type + ' / ' + keyword);
240
+ return null;
241
+ }
212
242
 
213
243
  return (
214
244
  <BottomSheet visible={visible}>