PluginProbe
Extendify / 3.2.1
Extendify v3.2.1
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / AutoLaunch / components / LaunchUpdate.jsx

LaunchUpdate.jsx in Extendify 3.2.1, at src/AutoLaunch/components/LaunchUpdate.jsx

60 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { WaitingOverlay } from '@auto-launch/components/Waiting';
2 import { forceReinstallPlugin, runUpdates } from '@auto-launch/functions/setup';
3 import { launchStrings } from '@auto-launch/strings';
4 import { digest } from '@shared/api/digest';
5 import { useCallback, useEffect } from '@wordpress/element';
6
7 // The reload is also the retry; the server bounds how many, so it can't loop.
8 export const LaunchUpdate = ({
9 pluginUpdateNeeded,
10 themeUpdateNeeded,
11 pluginUpdateViaRest,
12 pluginSlug,
13 attempt,
14 }) => {
15 const applyUpdates = useCallback(async () => {
16 // Run serially, not concurrently: two WP upgraders fight over the shared
17 // maintenance flag and filesystem.
18 const phpUpdateNeeded =
19 themeUpdateNeeded || (pluginUpdateNeeded && !pluginUpdateViaRest);
20 try {
21 if (phpUpdateNeeded) {
22 const result = await runUpdates();
23 if (result?.errors?.length) {
24 throw new Error(result.errors.join('; '));
25 }
26 }
27 if (pluginUpdateNeeded && pluginUpdateViaRest) {
28 await forceReinstallPlugin(pluginSlug);
29 }
30 } catch (error) {
31 digest({
32 error,
33 details: { source: 'auto-launch', caller: 'launch-update', attempt },
34 });
35 } finally {
36 window.location.reload();
37 }
38 }, [
39 pluginUpdateNeeded,
40 themeUpdateNeeded,
41 pluginUpdateViaRest,
42 pluginSlug,
43 attempt,
44 ]);
45
46 useEffect(() => {
47 applyUpdates();
48 }, [applyUpdates]);
49
50 const strings = launchStrings();
51
52 return (
53 <WaitingOverlay
54 show
55 message={strings.updating}
56 note={strings.updatingNote}
57 />
58 );
59 };
60