| @@ -1,7 +1,6 @@ | ||
| 1 | 1 | import { useLaunchDataStore } from '@auto-launch/state/launch-data'; |
| 2 | 2 | import { digest } from '@shared/api/digest'; |
| 3 | -import { __ } from '@wordpress/i18n'; | |
| 4 | 3 | |
| 5 | 4 | export const setStatus = (msg) => { |
| 6 | 5 | useLaunchDataStore.getState().addStatusMessage(msg); |
| 7 | 6 | }; |
| @@ -14,9 +13,9 @@ | ||
| 14 | 13 | return await fn(); |
| 15 | 14 | } catch (_) { |
| 16 | 15 | setErrorMessage( |
| 17 | 16 | // translators: This is an error message shown to the user when a network request fails and is being retried |
| 18 | - __('The network seems unstable. Retrying...', 'extendify-local'), | |
| 17 | + launchStrings().errorUnstable, | |
| 19 | 18 | ); |
| 20 | 19 | await wait(1000); |
| 21 | 20 | const res = await fn(); |
| 22 | 21 | setErrorMessage(null); |
| @@ -27,13 +26,10 @@ | ||
| 27 | 26 | export const failWithFallback = async (fn, fallback, errDetails = {}) => { |
| 28 | 27 | try { |
| 29 | 28 | return await fn(); |
| 30 | 29 | } catch (error) { |
| 31 | - digest({ | |
| 32 | - ...errDetails, | |
| 33 | - error: errDetails?.error ?? error, | |
| 34 | - source: 'auto-launch', | |
| 35 | - }); | |
| 30 | + const { error: reported = error, ...details } = errDetails; | |
| 31 | + digest({ error: reported, details: { source: 'auto-launch', ...details } }); | |
| 36 | 32 | return fallback; |
| 37 | 33 | } |
| 38 | 34 | }; |
| 39 | 35 | |
| @@ -38,8 +34,9 @@ | ||
| 38 | 34 | }; |
| 39 | 35 | |
| 40 | 36 | export const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms)); |
| 41 | 37 | |
| 38 | +import { launchStrings } from '@auto-launch/strings'; | |
| 42 | 39 | import apiFetch from '@wordpress/api-fetch'; |
| 43 | 40 | |
| 44 | 41 | export async function apiFetchWithTimeout(options = {}, timeoutMs = 30000) { |
| 45 | 42 | const controller = new AbortController(); |