Refactor ScriptLoading, removed timeout feature

Refactor SmartButton render hooks
This commit is contained in:
Pedro Silva 2023-09-07 09:13:57 +01:00
parent cf796d7374
commit bf92f8942d
No known key found for this signature in database
GPG key ID: E2EE20C0669D24B3
2 changed files with 16 additions and 21 deletions

View file

@ -7,8 +7,7 @@ import {keysToCamelCase} from "./Utils";
// This component may be used by multiple modules. This assures that options are shared between all instances.
let options = window.ppcpWidgetBuilder = window.ppcpWidgetBuilder || {
isLoading: false,
onLoadedCallbacks: [],
loadingWaitTime: 5000 // 5 seconds
onLoadedCallbacks: []
};
export const loadPaypalScript = (config, onLoaded) => {
@ -27,13 +26,6 @@ export const loadPaypalScript = (config, onLoaded) => {
}
options.isLoading = true;
// Arm a timeout so the module isn't locked on isLoading state on failure.
let loadingTimeout = setTimeout(() => {
console.error('Failed to load PayPal script.');
options.isLoading = false;
options.onLoadedCallbacks = [];
}, options.loadingWaitTime);
// Callback to be called once the PayPal script is loaded.
const callback = (paypal) => {
widgetBuilder.setPaypal(paypal);
@ -44,7 +36,6 @@ export const loadPaypalScript = (config, onLoaded) => {
options.isLoading = false;
options.onLoadedCallbacks = [];
clearTimeout(loadingTimeout);
}
// Build the PayPal script options.