← All changes
|
src/Shared/components/ProductAccountActivation/usePluginsActivation.js
+10
-1
3.1.5
→
trunk
View file →
| @@ -10,8 +10,14 @@ | ||
| 10 | 10 | completed: 'completed', |
| 11 | 11 | skipped: 'skipped', |
| 12 | 12 | }; |
| 13 | 13 | |
| 14 | +export const ACCOUNT_STATUS = { | |
| 15 | + pending: 'pending', | |
| 16 | + success: 'success', | |
| 17 | + error: 'error', | |
| 18 | +}; | |
| 19 | + | |
| 14 | 20 | export const getPluginsScriptData = async ([slugs, ineligible]) => { |
| 15 | 21 | const params = new URLSearchParams(slugs.map((slug) => ['plugins', slug])); |
| 16 | 22 | for (const slug of ineligible) { |
| 17 | 23 | params.append('ineligible', slug); |
| @@ -29,8 +35,9 @@ | ||
| 29 | 35 | selectedPlugins, |
| 30 | 36 | status, |
| 31 | 37 | context, |
| 32 | 38 | }) => { |
| 39 | + // Losing this record must not cost the account it was recording. | |
| 33 | 40 | await fetch(`${AI_HOST}/api/plugins/activate`, { |
| 34 | 41 | method: 'PATCH', |
| 35 | 42 | headers: { 'Content-Type': 'application/json' }, |
| 36 | 43 | body: JSON.stringify({ |
| @@ -39,9 +46,11 @@ | ||
| 39 | 46 | selectedPlugins, |
| 40 | 47 | status, |
| 41 | 48 | context, |
| 42 | 49 | }), |
| 43 | - }); | |
| 50 | + // The copy invites closing the window; the settled write has to outlive it. | |
| 51 | + keepalive: true, | |
| 52 | + }).catch(() => {}); | |
| 44 | 53 | }; |
| 45 | 54 | |
| 46 | 55 | export const usePluginsActivation = (plugins, ineligible = []) => { |
| 47 | 56 | const slugs = plugins.map((plugin) => plugin.slug); |