apps-sdk 1.0.151 → 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 +1 -1
- package/src/components/PayWall.js +35 -6
package/package.json
CHANGED
|
@@ -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
|
}
|
|
@@ -100,6 +128,9 @@ class PayWall extends React.Component {
|
|
|
100
128
|
|
|
101
129
|
async componentDidUpdate(prevProps) {
|
|
102
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);
|
|
103
134
|
await this.fetchAndModifyHTML();
|
|
104
135
|
setTimeout(() => {
|
|
105
136
|
Networking.sendEvent('scene', 'payment_card', {
|
|
@@ -201,15 +232,13 @@ class PayWall extends React.Component {
|
|
|
201
232
|
render() {
|
|
202
233
|
const { visible, onClose, type, keyword } = this.props;
|
|
203
234
|
if (PayWallLogic.paywallJS === '' || Object.keys(this.paywallData).length === 0) {
|
|
204
|
-
this.
|
|
205
|
-
// config.DEBUG_MODE && console.log('PayWallLogic.paywallJS:', PayWallLogic.paywallJS);
|
|
206
|
-
// config.DEBUG_MODE && console.log('PayWallLogic.paywallJS type:', typeof PayWallLogic.paywallJS);
|
|
235
|
+
this.getPayWallDataWithRetry(type, keyword);
|
|
207
236
|
}
|
|
208
237
|
|
|
209
238
|
if (!this.paywallData.url) {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
239
|
+
config.DEBUG_MODE && console.log('PayWallLogic: paywallData no tiene url para este type / keyword -> ' + type + ' / ' + keyword);
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
213
242
|
|
|
214
243
|
return (
|
|
215
244
|
<BottomSheet visible={visible}>
|