@wordpress/editor 14.40.2-next.v.202602271551.0 → 14.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/components/collaborators-presence/index.cjs +2 -2
- package/build/components/collaborators-presence/index.cjs.map +1 -1
- package/build/components/collaborators-presence/list.cjs +2 -2
- package/build/components/collaborators-presence/list.cjs.map +1 -1
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs +174 -0
- package/build/components/collaborators-presence/use-collaborator-notifications.cjs.map +7 -0
- package/build/components/editor-interface/index.cjs +2 -0
- package/build/components/editor-interface/index.cjs.map +2 -2
- package/build/components/page-attributes/parent.cjs +0 -1
- package/build/components/page-attributes/parent.cjs.map +2 -2
- package/build/components/post-author/panel.cjs +0 -1
- package/build/components/post-author/panel.cjs.map +2 -2
- package/build/components/post-locked-modal/index.cjs +30 -14
- package/build/components/post-locked-modal/index.cjs.map +3 -3
- package/build/components/post-url/panel.cjs +0 -1
- package/build/components/post-url/panel.cjs.map +2 -2
- package/build/components/sync-connection-modal/index.cjs +78 -27
- package/build/components/sync-connection-modal/index.cjs.map +3 -3
- package/build/components/sync-connection-modal/use-retry-countdown.cjs +74 -0
- package/build/components/sync-connection-modal/use-retry-countdown.cjs.map +7 -0
- package/build/store/selectors.cjs +3 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build/utils/sync-error-messages.cjs +16 -12
- package/build/utils/sync-error-messages.cjs.map +2 -2
- package/build-module/components/collaborators-presence/index.mjs +2 -2
- package/build-module/components/collaborators-presence/index.mjs.map +1 -1
- package/build-module/components/collaborators-presence/list.mjs +2 -2
- package/build-module/components/collaborators-presence/list.mjs.map +1 -1
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs +151 -0
- package/build-module/components/collaborators-presence/use-collaborator-notifications.mjs.map +7 -0
- package/build-module/components/editor-interface/index.mjs +2 -0
- package/build-module/components/editor-interface/index.mjs.map +2 -2
- package/build-module/components/page-attributes/parent.mjs +0 -1
- package/build-module/components/page-attributes/parent.mjs.map +2 -2
- package/build-module/components/post-author/panel.mjs +0 -1
- package/build-module/components/post-author/panel.mjs.map +2 -2
- package/build-module/components/post-locked-modal/index.mjs +30 -14
- package/build-module/components/post-locked-modal/index.mjs.map +2 -2
- package/build-module/components/post-url/panel.mjs +0 -1
- package/build-module/components/post-url/panel.mjs.map +2 -2
- package/build-module/components/sync-connection-modal/index.mjs +83 -30
- package/build-module/components/sync-connection-modal/index.mjs.map +2 -2
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs +49 -0
- package/build-module/components/sync-connection-modal/use-retry-countdown.mjs.map +7 -0
- package/build-module/store/selectors.mjs +3 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-module/utils/sync-error-messages.mjs +16 -12
- package/build-module/utils/sync-error-messages.mjs.map +2 -2
- package/build-style/style-rtl.css +6 -22
- package/build-style/style.css +6 -22
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts +9 -0
- package/build-types/components/collaborators-presence/use-collaborator-notifications.d.ts.map +1 -0
- package/build-types/components/editor-interface/index.d.ts.map +1 -1
- package/build-types/components/page-attributes/parent.d.ts.map +1 -1
- package/build-types/components/post-author/panel.d.ts.map +1 -1
- package/build-types/components/post-locked-modal/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-modal/index.d.ts.map +1 -1
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts +9 -0
- package/build-types/components/sync-connection-modal/use-retry-countdown.d.ts.map +1 -0
- package/build-types/store/selectors.d.ts.map +1 -1
- package/build-types/utils/sync-error-messages.d.ts +1 -1
- package/build-types/utils/sync-error-messages.d.ts.map +1 -1
- package/package.json +44 -44
- package/src/components/collaborators-presence/test/use-collaborator-notifications.ts +454 -0
- package/src/components/collaborators-presence/use-collaborator-notifications.ts +258 -0
- package/src/components/editor-interface/index.js +5 -0
- package/src/components/page-attributes/parent.js +0 -1
- package/src/components/post-author/panel.js +0 -1
- package/src/components/post-locked-modal/index.js +46 -23
- package/src/components/post-url/panel.js +0 -1
- package/src/components/post-url/style.scss +0 -5
- package/src/components/sync-connection-modal/index.js +97 -37
- package/src/components/sync-connection-modal/style.scss +6 -8
- package/src/components/sync-connection-modal/use-retry-countdown.js +70 -0
- package/src/store/selectors.js +5 -0
- package/src/utils/sync-error-messages.js +17 -12
- package/src/utils/test/sync-error-messages.js +57 -0
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
import { useSelect, select } from "@wordpress/data";
|
|
3
3
|
import { useCopyToClipboard } from "@wordpress/compose";
|
|
4
4
|
import { serialize } from "@wordpress/blocks";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
store as coreDataStore,
|
|
7
|
+
privateApis as coreDataPrivateApis
|
|
8
|
+
} from "@wordpress/core-data";
|
|
6
9
|
import {
|
|
7
10
|
privateApis,
|
|
8
11
|
store as blockEditorStore
|
|
@@ -10,22 +13,33 @@ import {
|
|
|
10
13
|
import {
|
|
11
14
|
Button,
|
|
12
15
|
Modal,
|
|
13
|
-
Icon,
|
|
14
16
|
__experimentalHStack as HStack,
|
|
15
17
|
__experimentalVStack as VStack
|
|
16
18
|
} from "@wordpress/components";
|
|
17
19
|
import { useState, useEffect, useRef } from "@wordpress/element";
|
|
18
|
-
import { __ } from "@wordpress/i18n";
|
|
19
|
-
import { error as errorIcon } from "@wordpress/icons";
|
|
20
|
+
import { __, sprintf, _n } from "@wordpress/i18n";
|
|
20
21
|
import { getSyncErrorMessages } from "../../utils/sync-error-messages.mjs";
|
|
22
|
+
import { store as editorStore } from "../../store/index.mjs";
|
|
21
23
|
import { unlock } from "../../lock-unlock.mjs";
|
|
24
|
+
import { useRetryCountdown } from "./use-retry-countdown.mjs";
|
|
22
25
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
23
26
|
var { BlockCanvasCover } = unlock(privateApis);
|
|
27
|
+
var { retrySyncConnection } = unlock(coreDataPrivateApis);
|
|
24
28
|
var INITIAL_DISCONNECTED_DEBOUNCE_MS = 5e3;
|
|
29
|
+
var noop = () => {
|
|
30
|
+
};
|
|
25
31
|
function SyncConnectionModal() {
|
|
26
|
-
const connectionState = useSelect((selectFn) => {
|
|
27
|
-
|
|
32
|
+
const { connectionState, postType } = useSelect((selectFn) => {
|
|
33
|
+
const currentPostType = selectFn(editorStore).getCurrentPostType();
|
|
34
|
+
return {
|
|
35
|
+
connectionState: selectFn(coreDataStore).getSyncConnectionStatus() || null,
|
|
36
|
+
postType: currentPostType ? selectFn(coreDataStore).getPostType(currentPostType) : null
|
|
37
|
+
};
|
|
28
38
|
}, []);
|
|
39
|
+
const { secondsRemaining, markRetrying } = useRetryCountdown(
|
|
40
|
+
connectionState?.retryInMs,
|
|
41
|
+
connectionState?.status
|
|
42
|
+
);
|
|
29
43
|
const copyButtonRef = useCopyToClipboard(() => {
|
|
30
44
|
const blocks = select(blockEditorStore).getBlocks();
|
|
31
45
|
return serialize(blocks);
|
|
@@ -33,20 +47,21 @@ function SyncConnectionModal() {
|
|
|
33
47
|
const [syncConnectionMessage, setSyncConnectionMessage] = useState(null);
|
|
34
48
|
const debounceTimerRef = useRef(null);
|
|
35
49
|
const hasInitializedRef = useRef(false);
|
|
50
|
+
const connectionStatus = connectionState?.status;
|
|
51
|
+
const connectionErrorCode = connectionState?.error?.code;
|
|
36
52
|
useEffect(() => {
|
|
37
|
-
const status = connectionState?.status;
|
|
38
53
|
if (debounceTimerRef.current) {
|
|
39
54
|
clearTimeout(debounceTimerRef.current);
|
|
40
55
|
debounceTimerRef.current = null;
|
|
41
56
|
}
|
|
42
|
-
if (
|
|
57
|
+
if (connectionStatus === "connected") {
|
|
43
58
|
hasInitializedRef.current = true;
|
|
44
59
|
setSyncConnectionMessage(null);
|
|
45
|
-
} else if (
|
|
60
|
+
} else if (connectionStatus === "disconnected") {
|
|
46
61
|
const showModal = () => {
|
|
47
62
|
hasInitializedRef.current = true;
|
|
48
63
|
setSyncConnectionMessage(
|
|
49
|
-
getSyncErrorMessages(
|
|
64
|
+
getSyncErrorMessages({ code: connectionErrorCode })
|
|
50
65
|
);
|
|
51
66
|
};
|
|
52
67
|
if (hasInitializedRef.current) {
|
|
@@ -63,48 +78,86 @@ function SyncConnectionModal() {
|
|
|
63
78
|
clearTimeout(debounceTimerRef.current);
|
|
64
79
|
}
|
|
65
80
|
};
|
|
66
|
-
}, [
|
|
81
|
+
}, [connectionStatus, connectionErrorCode]);
|
|
67
82
|
if (!syncConnectionMessage) {
|
|
68
83
|
return null;
|
|
69
84
|
}
|
|
70
|
-
const { title, description } = syncConnectionMessage;
|
|
85
|
+
const { title, description, canRetry } = syncConnectionMessage;
|
|
86
|
+
let retryCountdownText;
|
|
87
|
+
if (secondsRemaining > 0) {
|
|
88
|
+
retryCountdownText = sprintf(
|
|
89
|
+
/* translators: %d: number of seconds until retry */
|
|
90
|
+
_n(
|
|
91
|
+
"Retrying connection in %d second\u2026",
|
|
92
|
+
"Retrying connection in %d seconds\u2026",
|
|
93
|
+
secondsRemaining
|
|
94
|
+
),
|
|
95
|
+
secondsRemaining
|
|
96
|
+
);
|
|
97
|
+
} else if (secondsRemaining === 0) {
|
|
98
|
+
retryCountdownText = __("Retrying\u2026");
|
|
99
|
+
}
|
|
100
|
+
let editPostHref = "edit.php";
|
|
101
|
+
if (postType?.slug) {
|
|
102
|
+
editPostHref = `edit.php?post_type=${postType.slug}`;
|
|
103
|
+
}
|
|
104
|
+
const isRetrying = secondsRemaining === 0;
|
|
71
105
|
return /* @__PURE__ */ jsx(BlockCanvasCover.Fill, { children: /* @__PURE__ */ jsx(
|
|
72
106
|
Modal,
|
|
73
107
|
{
|
|
74
|
-
|
|
75
|
-
icon: errorIcon,
|
|
108
|
+
className: "editor-sync-connection-modal",
|
|
76
109
|
isDismissible: false,
|
|
77
|
-
|
|
78
|
-
onRequestClose: () => {
|
|
79
|
-
},
|
|
110
|
+
onRequestClose: noop,
|
|
80
111
|
shouldCloseOnClickOutside: false,
|
|
81
112
|
shouldCloseOnEsc: false,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
/* @__PURE__ */ jsx("p", {
|
|
86
|
-
/* @__PURE__ */
|
|
113
|
+
size: "medium",
|
|
114
|
+
title,
|
|
115
|
+
children: /* @__PURE__ */ jsxs(VStack, { spacing: 6, children: [
|
|
116
|
+
/* @__PURE__ */ jsx("p", { children: description }),
|
|
117
|
+
retryCountdownText && /* @__PURE__ */ jsx("p", { className: "editor-sync-connection-modal__retry-countdown", children: retryCountdownText }),
|
|
118
|
+
/* @__PURE__ */ jsxs(HStack, { justify: "right", children: [
|
|
87
119
|
/* @__PURE__ */ jsx(
|
|
88
120
|
Button,
|
|
89
121
|
{
|
|
90
122
|
__next40pxDefaultSize: true,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
123
|
+
href: editPostHref,
|
|
124
|
+
isDestructive: true,
|
|
125
|
+
variant: "tertiary",
|
|
126
|
+
children: sprintf(
|
|
127
|
+
/* translators: %s: Post type name (e.g., "Posts", "Pages"). */
|
|
128
|
+
__("Back to %s"),
|
|
129
|
+
postType?.labels?.name ?? __("Posts")
|
|
130
|
+
)
|
|
94
131
|
}
|
|
95
132
|
),
|
|
96
133
|
/* @__PURE__ */ jsx(
|
|
97
134
|
Button,
|
|
98
135
|
{
|
|
99
136
|
__next40pxDefaultSize: true,
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
137
|
+
ref: copyButtonRef,
|
|
138
|
+
variant: canRetry ? "secondary" : "primary",
|
|
139
|
+
children: __("Copy Post Content")
|
|
140
|
+
}
|
|
141
|
+
),
|
|
142
|
+
canRetry && /* @__PURE__ */ jsx(
|
|
143
|
+
Button,
|
|
144
|
+
{
|
|
145
|
+
__next40pxDefaultSize: true,
|
|
146
|
+
"aria-disabled": isRetrying,
|
|
147
|
+
isBusy: isRetrying,
|
|
148
|
+
variant: "primary",
|
|
149
|
+
onClick: () => {
|
|
150
|
+
if (isRetrying) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
markRetrying();
|
|
154
|
+
retrySyncConnection();
|
|
155
|
+
},
|
|
156
|
+
children: __("Retry")
|
|
104
157
|
}
|
|
105
158
|
)
|
|
106
159
|
] })
|
|
107
|
-
] })
|
|
160
|
+
] })
|
|
108
161
|
}
|
|
109
162
|
) });
|
|
110
163
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/components/sync-connection-modal/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { serialize } from '@wordpress/blocks';\nimport {
|
|
5
|
-
"mappings": ";AAGA,SAAS,WAAW,cAAc;AAClC,SAAS,0BAA0B;AACnC,SAAS,iBAAiB;AAC1B,
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useSelect, select } from '@wordpress/data';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { serialize } from '@wordpress/blocks';\nimport {\n\tstore as coreDataStore,\n\tprivateApis as coreDataPrivateApis,\n} from '@wordpress/core-data';\nimport {\n\tprivateApis,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tModal,\n\t__experimentalHStack as HStack,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { __, sprintf, _n } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { getSyncErrorMessages } from '../../utils/sync-error-messages';\nimport { store as editorStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\nimport { useRetryCountdown } from './use-retry-countdown';\n\nconst { BlockCanvasCover } = unlock( privateApis );\nconst { retrySyncConnection } = unlock( coreDataPrivateApis );\n\n// Debounce time for initial disconnected status to allow connection to establish.\nconst INITIAL_DISCONNECTED_DEBOUNCE_MS = 5000;\nconst noop = () => {};\n\n/**\n * Sync connection modal that displays when any entity reports a disconnection.\n * Uses BlockCanvasCover.Fill to render in the block canvas.\n *\n * @return {Element|null} The modal component or null if not disconnected.\n */\nexport function SyncConnectionModal() {\n\tconst { connectionState, postType } = useSelect( ( selectFn ) => {\n\t\tconst currentPostType = selectFn( editorStore ).getCurrentPostType();\n\t\treturn {\n\t\t\tconnectionState:\n\t\t\t\tselectFn( coreDataStore ).getSyncConnectionStatus() || null,\n\t\t\tpostType: currentPostType\n\t\t\t\t? selectFn( coreDataStore ).getPostType( currentPostType )\n\t\t\t\t: null,\n\t\t};\n\t}, [] );\n\n\tconst { secondsRemaining, markRetrying } = useRetryCountdown(\n\t\tconnectionState?.retryInMs,\n\t\tconnectionState?.status\n\t);\n\n\tconst copyButtonRef = useCopyToClipboard( () => {\n\t\tconst blocks = select( blockEditorStore ).getBlocks();\n\t\treturn serialize( blocks );\n\t} );\n\tconst [ syncConnectionMessage, setSyncConnectionMessage ] =\n\t\tuseState( null );\n\tconst debounceTimerRef = useRef( null );\n\t// Track whether we've passed the initial load phase.\n\t// Once true, disconnected status will show immediately without debounce.\n\tconst hasInitializedRef = useRef( false );\n\n\tconst connectionStatus = connectionState?.status;\n\tconst connectionErrorCode = connectionState?.error?.code;\n\n\tuseEffect( () => {\n\t\t// Clear any pending debounce timer when status changes.\n\t\tif ( debounceTimerRef.current ) {\n\t\t\tclearTimeout( debounceTimerRef.current );\n\t\t\tdebounceTimerRef.current = null;\n\t\t}\n\n\t\tif ( connectionStatus === 'connected' ) {\n\t\t\thasInitializedRef.current = true;\n\t\t\tsetSyncConnectionMessage( null );\n\t\t} else if ( connectionStatus === 'disconnected' ) {\n\t\t\tconst showModal = () => {\n\t\t\t\thasInitializedRef.current = true;\n\t\t\t\tsetSyncConnectionMessage(\n\t\t\t\t\tgetSyncErrorMessages( { code: connectionErrorCode } )\n\t\t\t\t);\n\t\t\t};\n\n\t\t\t// Debounce only on first load to allow connection to establish.\n\t\t\tif ( hasInitializedRef.current ) {\n\t\t\t\tshowModal();\n\t\t\t} else {\n\t\t\t\tdebounceTimerRef.current = setTimeout(\n\t\t\t\t\tshowModal,\n\t\t\t\t\tINITIAL_DISCONNECTED_DEBOUNCE_MS\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\treturn () => {\n\t\t\tif ( debounceTimerRef.current ) {\n\t\t\t\tclearTimeout( debounceTimerRef.current );\n\t\t\t}\n\t\t};\n\t}, [ connectionStatus, connectionErrorCode ] );\n\n\tif ( ! syncConnectionMessage ) {\n\t\treturn null;\n\t}\n\n\tconst { title, description, canRetry } = syncConnectionMessage;\n\n\tlet retryCountdownText;\n\tif ( secondsRemaining > 0 ) {\n\t\tretryCountdownText = sprintf(\n\t\t\t/* translators: %d: number of seconds until retry */\n\t\t\t_n(\n\t\t\t\t'Retrying connection in %d second\\u2026',\n\t\t\t\t'Retrying connection in %d seconds\\u2026',\n\t\t\t\tsecondsRemaining\n\t\t\t),\n\t\t\tsecondsRemaining\n\t\t);\n\t} else if ( secondsRemaining === 0 ) {\n\t\tretryCountdownText = __( 'Retrying\\u2026' );\n\t}\n\n\tlet editPostHref = 'edit.php';\n\tif ( postType?.slug ) {\n\t\teditPostHref = `edit.php?post_type=${ postType.slug }`;\n\t}\n\n\tconst isRetrying = secondsRemaining === 0;\n\n\treturn (\n\t\t<BlockCanvasCover.Fill>\n\t\t\t<Modal\n\t\t\t\tclassName=\"editor-sync-connection-modal\"\n\t\t\t\tisDismissible={ false }\n\t\t\t\tonRequestClose={ noop }\n\t\t\t\tshouldCloseOnClickOutside={ false }\n\t\t\t\tshouldCloseOnEsc={ false }\n\t\t\t\tsize=\"medium\"\n\t\t\t\ttitle={ title }\n\t\t\t>\n\t\t\t\t<VStack spacing={ 6 }>\n\t\t\t\t\t<p>{ description }</p>\n\t\t\t\t\t{ retryCountdownText && (\n\t\t\t\t\t\t<p className=\"editor-sync-connection-modal__retry-countdown\">\n\t\t\t\t\t\t\t{ retryCountdownText }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t) }\n\t\t\t\t\t<HStack justify=\"right\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\thref={ editPostHref }\n\t\t\t\t\t\t\tisDestructive\n\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Post type name (e.g., \"Posts\", \"Pages\"). */\n\t\t\t\t\t\t\t\t__( 'Back to %s' ),\n\t\t\t\t\t\t\t\tpostType?.labels?.name ?? __( 'Posts' )\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\tref={ copyButtonRef }\n\t\t\t\t\t\t\tvariant={ canRetry ? 'secondary' : 'primary' }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Copy Post Content' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t{ canRetry && (\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\t\t\t\taria-disabled={ isRetrying }\n\t\t\t\t\t\t\t\tisBusy={ isRetrying }\n\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tif ( isRetrying ) {\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tmarkRetrying();\n\t\t\t\t\t\t\t\t\tretrySyncConnection();\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Retry' ) }\n\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</HStack>\n\t\t\t\t</VStack>\n\t\t\t</Modal>\n\t\t</BlockCanvasCover.Fill>\n\t);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ACnB,MAAK;AAAA,MACL;AAAA,MAEA,+BAAC,UAAO,SAAU,GACjB;AAAA,4BAAC,OAAI,uBAAa;AAAA,QAChB,sBACD,oBAAC,OAAE,WAAU,iDACV,8BACH;AAAA,QAED,qBAAC,UAAO,SAAQ,SACf;AAAA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,MAAO;AAAA,cACP,eAAa;AAAA,cACb,SAAQ;AAAA,cAEN;AAAA;AAAA,gBAED,GAAI,YAAa;AAAA,gBACjB,UAAU,QAAQ,QAAQ,GAAI,OAAQ;AAAA,cACvC;AAAA;AAAA,UACD;AAAA,UACA;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,KAAM;AAAA,cACN,SAAU,WAAW,cAAc;AAAA,cAEjC,aAAI,mBAAoB;AAAA;AAAA,UAC3B;AAAA,UACE,YACD;AAAA,YAAC;AAAA;AAAA,cACA,uBAAqB;AAAA,cACrB,iBAAgB;AAAA,cAChB,QAAS;AAAA,cACT,SAAQ;AAAA,cACR,SAAU,MAAM;AACf,oBAAK,YAAa;AACjB;AAAA,gBACD;AACA,6BAAa;AACb,oCAAoB;AAAA,cACrB;AAAA,cAEE,aAAI,OAAQ;AAAA;AAAA,UACf;AAAA,WAEF;AAAA,SACD;AAAA;AAAA,EACD,GACD;AAEF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// packages/editor/src/components/sync-connection-modal/use-retry-countdown.js
|
|
2
|
+
import { useState, useEffect, useRef } from "@wordpress/element";
|
|
3
|
+
var MIN_RETRYING_DISPLAY_MS = 600;
|
|
4
|
+
function useRetryCountdown(retryInMs, status) {
|
|
5
|
+
const [secondsRemaining, setSecondsRemaining] = useState(null);
|
|
6
|
+
const [isRetrying, setIsRetrying] = useState(false);
|
|
7
|
+
const retryAtRef = useRef(null);
|
|
8
|
+
const markRetrying = () => setIsRetrying(true);
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
if (!isRetrying) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const id = setTimeout(
|
|
14
|
+
() => setIsRetrying(false),
|
|
15
|
+
MIN_RETRYING_DISPLAY_MS
|
|
16
|
+
);
|
|
17
|
+
return () => clearTimeout(id);
|
|
18
|
+
}, [isRetrying]);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (status === "connected") {
|
|
21
|
+
setSecondsRemaining(null);
|
|
22
|
+
retryAtRef.current = null;
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (status !== "disconnected" || !retryInMs) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
const retryAt = Date.now() + retryInMs;
|
|
29
|
+
retryAtRef.current = retryAt;
|
|
30
|
+
setSecondsRemaining(Math.ceil(retryInMs / 1e3));
|
|
31
|
+
const intervalId = setInterval(() => {
|
|
32
|
+
const remaining = Math.ceil(
|
|
33
|
+
(retryAtRef.current - Date.now()) / 1e3
|
|
34
|
+
);
|
|
35
|
+
setSecondsRemaining(Math.max(0, remaining));
|
|
36
|
+
if (remaining <= 0) {
|
|
37
|
+
clearInterval(intervalId);
|
|
38
|
+
setIsRetrying(true);
|
|
39
|
+
}
|
|
40
|
+
}, 1e3);
|
|
41
|
+
return () => clearInterval(intervalId);
|
|
42
|
+
}, [retryInMs, status]);
|
|
43
|
+
const displaySeconds = isRetrying ? 0 : secondsRemaining;
|
|
44
|
+
return { secondsRemaining: displaySeconds, markRetrying };
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
useRetryCountdown
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=use-retry-countdown.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/components/sync-connection-modal/use-retry-countdown.js"],
|
|
4
|
+
"sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useRef } from '@wordpress/element';\n\nconst MIN_RETRYING_DISPLAY_MS = 600;\n\n/**\n * Hook that computes a countdown in seconds from a retryInMs value.\n *\n * @param {number|undefined} retryInMs Milliseconds until next retry.\n * @param {string|undefined} status Current connection status.\n * @return {Object} Object with `secondsRemaining` (number|null) and `markRetrying` callback.\n */\nexport function useRetryCountdown( retryInMs, status ) {\n\tconst [ secondsRemaining, setSecondsRemaining ] = useState( null );\n\tconst [ isRetrying, setIsRetrying ] = useState( false );\n\tconst retryAtRef = useRef( null );\n\n\t// Show \"Retrying\u2026\" for a minimum duration when manually triggered.\n\tconst markRetrying = () => setIsRetrying( true );\n\n\tuseEffect( () => {\n\t\tif ( ! isRetrying ) {\n\t\t\treturn;\n\t\t}\n\t\tconst id = setTimeout(\n\t\t\t() => setIsRetrying( false ),\n\t\t\tMIN_RETRYING_DISPLAY_MS\n\t\t);\n\t\treturn () => clearTimeout( id );\n\t}, [ isRetrying ] );\n\n\tuseEffect( () => {\n\t\t// Only clear countdown when explicitly connected.\n\t\tif ( status === 'connected' ) {\n\t\t\tsetSecondsRemaining( null );\n\t\t\tretryAtRef.current = null;\n\t\t\treturn;\n\t\t}\n\n\t\t// For transient states (e.g. 'connecting' during a retry attempt)\n\t\t// or when retryInMs is not yet available, keep the previous\n\t\t// countdown value to avoid a brief flash.\n\t\tif ( status !== 'disconnected' || ! retryInMs ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst retryAt = Date.now() + retryInMs;\n\t\tretryAtRef.current = retryAt;\n\t\tsetSecondsRemaining( Math.ceil( retryInMs / 1000 ) );\n\n\t\tconst intervalId = setInterval( () => {\n\t\t\tconst remaining = Math.ceil(\n\t\t\t\t( retryAtRef.current - Date.now() ) / 1000\n\t\t\t);\n\t\t\tsetSecondsRemaining( Math.max( 0, remaining ) );\n\t\t\tif ( remaining <= 0 ) {\n\t\t\t\tclearInterval( intervalId );\n\t\t\t\tsetIsRetrying( true );\n\t\t\t}\n\t\t}, 1000 );\n\n\t\treturn () => clearInterval( intervalId );\n\t}, [ retryInMs, status ] );\n\n\tconst displaySeconds = isRetrying ? 0 : secondsRemaining;\n\n\treturn { secondsRemaining: displaySeconds, markRetrying };\n}\n"],
|
|
5
|
+
"mappings": ";AAGA,SAAS,UAAU,WAAW,cAAc;AAE5C,IAAM,0BAA0B;AASzB,SAAS,kBAAmB,WAAW,QAAS;AACtD,QAAM,CAAE,kBAAkB,mBAAoB,IAAI,SAAU,IAAK;AACjE,QAAM,CAAE,YAAY,aAAc,IAAI,SAAU,KAAM;AACtD,QAAM,aAAa,OAAQ,IAAK;AAGhC,QAAM,eAAe,MAAM,cAAe,IAAK;AAE/C,YAAW,MAAM;AAChB,QAAK,CAAE,YAAa;AACnB;AAAA,IACD;AACA,UAAM,KAAK;AAAA,MACV,MAAM,cAAe,KAAM;AAAA,MAC3B;AAAA,IACD;AACA,WAAO,MAAM,aAAc,EAAG;AAAA,EAC/B,GAAG,CAAE,UAAW,CAAE;AAElB,YAAW,MAAM;AAEhB,QAAK,WAAW,aAAc;AAC7B,0BAAqB,IAAK;AAC1B,iBAAW,UAAU;AACrB;AAAA,IACD;AAKA,QAAK,WAAW,kBAAkB,CAAE,WAAY;AAC/C;AAAA,IACD;AAEA,UAAM,UAAU,KAAK,IAAI,IAAI;AAC7B,eAAW,UAAU;AACrB,wBAAqB,KAAK,KAAM,YAAY,GAAK,CAAE;AAEnD,UAAM,aAAa,YAAa,MAAM;AACrC,YAAM,YAAY,KAAK;AAAA,SACpB,WAAW,UAAU,KAAK,IAAI,KAAM;AAAA,MACvC;AACA,0BAAqB,KAAK,IAAK,GAAG,SAAU,CAAE;AAC9C,UAAK,aAAa,GAAI;AACrB,sBAAe,UAAW;AAC1B,sBAAe,IAAK;AAAA,MACrB;AAAA,IACD,GAAG,GAAK;AAER,WAAO,MAAM,cAAe,UAAW;AAAA,EACxC,GAAG,CAAE,WAAW,MAAO,CAAE;AAEzB,QAAM,iBAAiB,aAAa,IAAI;AAExC,SAAO,EAAE,kBAAkB,gBAAgB,aAAa;AACzD;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -748,6 +748,9 @@ function isPublishSidebarOpened(state) {
|
|
|
748
748
|
}
|
|
749
749
|
var isCollaborationEnabledForCurrentPost = createRegistrySelector(
|
|
750
750
|
(select) => (state) => {
|
|
751
|
+
if (!unlock(select(coreStore)).isCollaborationSupported()) {
|
|
752
|
+
return false;
|
|
753
|
+
}
|
|
751
754
|
const currentPostType = getCurrentPostType(state);
|
|
752
755
|
const entityConfig = select(coreStore).getEntityConfig(
|
|
753
756
|
"postType",
|