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/Agent/state/global.js +14 -4 3.0.4 → trunk View file →
@@ -2,8 +2,19 @@
2 2 import { isInTheFuture } from '@wordpress/date';
3 3 import { create } from 'zustand';
4 4 import { devtools, persist } from 'zustand/middleware';
5 5
6 +// Mirrors Tailwind's --breakpoint-md, where WP's admin bar goes big.
7 +export const DESKTOP_MIN_WIDTH = 783;
8 +
9 +const url = new URL(window.location.href);
10 +const openAgentFromUrl = url.searchParams.has('extendify-open-agent');
11 +if (openAgentFromUrl) {
12 + url.searchParams.delete('extendify-open-agent');
13 + window.history.replaceState({}, '', url.toString());
14 +}
15 +const forceOpen = window.extAgentData?.startOnboarding || openAgentFromUrl;
16 +
6 17 export const useGlobalStore = create()(
7 18 persist(
8 19 devtools(
9 20 (set, get) => ({
@@ -10,12 +21,12 @@
10 21 retryAfter: undefined,
11 22 open: true,
12 23 minimized: false,
13 24 // e.g. floating, docked-left, docked-right ?
14 - mode: window.extAgentData.agentPosition,
25 + mode: window.extAgentData?.agentPosition,
15 26 queuedTour: null,
16 27 scratch: {},
17 - isMobile: window.innerWidth < 768,
28 + isMobile: window.innerWidth < DESKTOP_MIN_WIDTH,
18 29 setIsMobile: (isMobile) => {
19 30 if (get().isMobile === isMobile) return;
20 31 set({ isMobile });
21 32 },
@@ -62,10 +73,9 @@
62 73 ),
63 74 {
64 75 name: `extendify-agent-global-${window.extSharedData.siteId}`,
65 76 merge: (persistedState, currentState) => {
66 - // force open if we hit the success page
67 - const open = window.extAgentData?.startOnboarding
77 + const open = forceOpen
68 78 ? true
69 79 : (persistedState?.open ?? currentState.open);
70 80 return { ...currentState, ...persistedState, open };
71 81 },