(cb)
| 1100 | } |
| 1101 | |
| 1102 | loadingWrapper(cb) { |
| 1103 | // wrapping in a setTimeout to smooth out initial iab animation |
| 1104 | const wrappedCb = () => setTimeout(cb, LOADING_WRAPPER_TIMEOUT); |
| 1105 | |
| 1106 | if (this.IABReady) { |
| 1107 | wrappedCb(); |
| 1108 | } else { |
| 1109 | this.onGoingProcess.set('generalAwaiting'); |
| 1110 | |
| 1111 | let attempts = 0; |
| 1112 | const interval = setInterval(() => { |
| 1113 | if (attempts >= IAB_LOADING_ATTEMPTS) { |
| 1114 | clear(); |
| 1115 | |
| 1116 | this.actionSheetProvider |
| 1117 | .createInfoSheet('default-error', { |
| 1118 | title: 'BitPay Card', |
| 1119 | msg: 'Uh oh, something went wrong please try again later.' |
| 1120 | }) |
| 1121 | .present(); |
| 1122 | } |
| 1123 | attempts++; |
| 1124 | }, IAB_LOADING_INTERVAL); |
| 1125 | |
| 1126 | const subscription = this.IABLoaded$.subscribe(() => { |
| 1127 | wrappedCb(); |
| 1128 | clear(); |
| 1129 | }); |
| 1130 | |
| 1131 | const clear = () => { |
| 1132 | clearInterval(interval); |
| 1133 | this.onGoingProcess.clear(); |
| 1134 | subscription && subscription.unsubscribe(); |
| 1135 | }; |
| 1136 | } |
| 1137 | } |
| 1138 | |
| 1139 | pause(): void { |
| 1140 | this._pausedState = this.isVisible; |
no test coverage detected