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
← All changes | src/AutoLaunch/state/launch-data.js +29 -10 3.0.43.2.1 View file →
@@ -1,8 +1,9 @@
1 1 import {
2 2 getDesignBuildShape,
3 3 getHomeShape,
4 4 getImagesShape,
5 + getLaunchDecisionsShape,
5 6 getLogoShape,
6 7 getPagesShape,
7 8 getPluginsShape,
8 9 getProfileShape,
@@ -8,11 +9,14 @@
8 9 getProfileShape,
9 10 getStringsShape,
10 11 getStyleShape,
11 12 } from '@auto-launch/fetchers/shape';
12 -import { __ } from '@wordpress/i18n';
13 +import { clearSiteImages } from '@auto-launch/functions/wp';
14 +import { launchStrings } from '@auto-launch/strings';
15 +import { siteImageUrls } from '@shared/lib/site-images';
16 +import { safeLocalStorage } from '@shared/state/safe-local-storage';
13 17 import { create } from 'zustand';
14 -import { devtools, persist } from 'zustand/middleware';
18 +import { createJSONStorage, devtools, persist } from 'zustand/middleware';
15 19 import { overrideWithUrlParams, urlParams, urlParamsShape } from './url-params';
16 20
17 21 const shapeToKeyValue = (shape) => {
18 22 return Object.fromEntries(
@@ -21,12 +25,14 @@
21 25 };
22 26
23 27 const initialState = {
24 28 go: false,
29 + showExtendifyCodeScreen: false,
25 30 // translators: this is for a action log UI. Keep it short
26 - statusMessages: [__('Booting things up', 'extendify-local')],
31 + statusMessages: [launchStrings().statusBooting],
27 32 errorMessage: null,
28 33 errorCount: 0,
34 + title: null,
29 35 description: null,
30 36 descriptionBackup: undefined,
31 37 descriptionRaw: null,
32 38 urlParams: {},
@@ -32,8 +38,11 @@
32 38 urlParams: {},
33 39 siteProfile: {
34 40 ...shapeToKeyValue(getProfileShape),
35 41 },
42 + launchDecisions: {
43 + ...shapeToKeyValue(getLaunchDecisionsShape),
44 + },
36 45 ...shapeToKeyValue(getLogoShape),
37 46 ...shapeToKeyValue(getPluginsShape),
38 47 ...shapeToKeyValue(getStyleShape),
39 48 ...shapeToKeyValue(getStringsShape),
@@ -54,10 +63,8 @@
54 63 title: undefined,
55 64 description: undefined,
56 65 descriptionBackup: undefined,
57 66 descriptionRaw: undefined,
58 - pulse: false,
59 - setPulse: (value) => set({ pulse: value }),
60 67 setData: (key, value) => {
61 68 if (!isValidKey(key)) return;
62 69 if (get()[key] === value) return; // avoid unnecessary updates
63 70 set({ [key]: value });
@@ -85,8 +92,9 @@
85 92 if (!isValidKey(key)) return;
86 93 newState[key] = get()[key];
87 94 });
88 95 }
96 + clearSiteImages().catch(() => null);
89 97 set(newState);
90 98 },
91 99 });
92 100
@@ -95,8 +103,9 @@
95 103
96 104 const keySchemas = {
97 105 urlParams: urlParamsShape,
98 106 siteProfile: getProfileShape,
107 + launchDecisions: getLaunchDecisionsShape,
99 108 ...Object.fromEntries(
100 109 [
101 110 getLogoShape,
102 111 getPluginsShape,
@@ -112,8 +121,9 @@
112 121
113 122 export const useLaunchDataStore = create(
114 123 persist(devtools(state, { name: 'Extendify Launch Data' }), {
115 124 name: `extendify-launch-data-${window.extSharedData.siteId}`,
125 + storage: createJSONStorage(() => safeLocalStorage),
116 126 merge: (p, current) => {
117 127 // Make sure the persisted state is valid and not corrupted.
118 128 const persisted = p && typeof p === 'object' ? p : {};
119 129
@@ -137,9 +147,12 @@
137 147 // If there's a URL param here it should override these values
138 148 title: title || persisted.title,
139 149 description: description || persisted.description,
140 150 descriptionRaw: description || persisted.descriptionRaw,
141 - descriptionBackup: persisted.descriptionBackup || description || title,
151 + descriptionBackup:
152 + persisted.descriptionBackup ||
153 + description ||
154 + (window.extLaunchData?.showLaunchTitle ? undefined : title),
142 155 go: go || persisted.go,
143 156 urlParams: {
144 157 title,
145 158 description,
@@ -158,19 +171,25 @@
158 171 const {
159 172 statusMessages,
160 173 errorMessage,
161 174 errorCount,
162 - pulse,
163 175 description,
164 176 descriptionRaw,
165 177 title,
178 + showExtendifyCodeScreen,
166 179 ...rest
167 180 } = state;
168 181 return Object.fromEntries(
169 - Object.entries(rest).filter(([, v]) =>
170 - Array.isArray(v) ? v.length > 0 : Boolean(v),
171 - ),
182 + Object.entries(rest).filter(([key, v]) => {
183 + // An empty set means the fetch failed; keeping it skips the retry.
184 + if (key === 'siteImages') return siteImageUrls(v).length > 0;
185 + return Array.isArray(v) ? v.length > 0 : Boolean(v);
186 + }),
172 187 );
173 188 },
174 189 }),
175 190 state,
176 191 );
192 +
193 +export const clearPersistedLaunchData = () => {
194 + useLaunchDataStore.persist.clearStorage();
195 +};