PluginProbe
Extendify / trunk
Extendify vtrunk
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 +19 -10 3.1.3 → trunk View file →
@@ -10,11 +10,13 @@
10 10 getStringsShape,
11 11 getStyleShape,
12 12 } from '@auto-launch/fetchers/shape';
13 13 import { clearSiteImages } from '@auto-launch/functions/wp';
14 -import { __ } from '@wordpress/i18n';
14 +import { launchStrings } from '@auto-launch/strings';
15 +import { siteImageUrls } from '@shared/lib/site-images';
16 +import { safeLocalStorage } from '@shared/state/safe-local-storage';
15 17 import { create } from 'zustand';
16 -import { devtools, persist } from 'zustand/middleware';
18 +import { createJSONStorage, devtools, persist } from 'zustand/middleware';
17 19 import { overrideWithUrlParams, urlParams, urlParamsShape } from './url-params';
18 20
19 21 const shapeToKeyValue = (shape) => {
20 22 return Object.fromEntries(
@@ -25,9 +27,9 @@
25 27 const initialState = {
26 28 go: false,
27 29 showExtendifyCodeScreen: false,
28 30 // translators: this is for a action log UI. Keep it short
29 - statusMessages: [__('Booting things up', 'extendify-local')],
31 + statusMessages: [launchStrings().statusBooting],
30 32 errorMessage: null,
31 33 errorCount: 0,
32 34 title: null,
33 35 description: null,
@@ -61,10 +63,8 @@
61 63 title: undefined,
62 64 description: undefined,
63 65 descriptionBackup: undefined,
64 66 descriptionRaw: undefined,
65 - pulse: false,
66 - setPulse: (value) => set({ pulse: value }),
67 67 setData: (key, value) => {
68 68 if (!isValidKey(key)) return;
69 69 if (get()[key] === value) return; // avoid unnecessary updates
70 70 set({ [key]: value });
@@ -121,8 +121,9 @@
121 121
122 122 export const useLaunchDataStore = create(
123 123 persist(devtools(state, { name: 'Extendify Launch Data' }), {
124 124 name: `extendify-launch-data-${window.extSharedData.siteId}`,
125 + storage: createJSONStorage(() => safeLocalStorage),
125 126 merge: (p, current) => {
126 127 // Make sure the persisted state is valid and not corrupted.
127 128 const persisted = p && typeof p === 'object' ? p : {};
128 129
@@ -146,9 +147,12 @@
146 147 // If there's a URL param here it should override these values
147 148 title: title || persisted.title,
148 149 description: description || persisted.description,
149 150 descriptionRaw: description || persisted.descriptionRaw,
150 - descriptionBackup: persisted.descriptionBackup || description || title,
151 + descriptionBackup:
152 + persisted.descriptionBackup ||
153 + description ||
154 + (window.extLaunchData?.showLaunchTitle ? undefined : title),
151 155 go: go || persisted.go,
152 156 urlParams: {
153 157 title,
154 158 description,
@@ -167,9 +171,8 @@
167 171 const {
168 172 statusMessages,
169 173 errorMessage,
170 174 errorCount,
171 - pulse,
172 175 description,
173 176 descriptionRaw,
174 177 title,
175 178 showExtendifyCodeScreen,
@@ -175,12 +178,18 @@
175 178 showExtendifyCodeScreen,
176 179 ...rest
177 180 } = state;
178 181 return Object.fromEntries(
179 - Object.entries(rest).filter(([, v]) =>
180 - Array.isArray(v) ? v.length > 0 : Boolean(v),
181 - ),
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 + }),
182 187 );
183 188 },
184 189 }),
185 190 state,
186 191 );
192 +
193 +export const clearPersistedLaunchData = () => {
194 + useLaunchDataStore.persist.clearStorage();
195 +};