mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 12:25:15 +08:00
Refactor ScriptLoading, removed timeout feature
Refactor SmartButton render hooks
This commit is contained in:
parent
cf796d7374
commit
bf92f8942d
2 changed files with 16 additions and 21 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue