MCPcopy
hub / github.com/bitpay/wallet / loadingWrapper

Method loadingWrapper

src/providers/in-app-browser/card.ts:1102–1137  ·  view source on GitHub ↗
(cb)

Source from the content-addressed store, hash-verified

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;

Callers 7

pairingMethod · 0.95
goToMethod · 0.80
openBitPayIdPageMethod · 0.80
openBitPayIdPageMethod · 0.80
openCardSettingsMethod · 0.80
orderBitPayCardMethod · 0.80
goToCardMethod · 0.80

Calls 4

subscribeMethod · 0.80
setMethod · 0.65
presentMethod · 0.45
createInfoSheetMethod · 0.45

Tested by

no test coverage detected