PluginProbe
Extendify / 3.0.5
Extendify v3.0.5
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 / Agent / hooks / useLockPost.js

useLockPost.js in Extendify 3.0.5, at src/Agent/hooks/useLockPost.js

21 lines 607 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import apiFetch from '@wordpress/api-fetch';
2 import { useEffect } from '@wordpress/element';
3
4 export const useLockPost = ({ postId, enabled }) => {
5 useEffect(() => {
6 if (!postId || !enabled) return;
7 let timeoutId;
8 const lockPost = async () => {
9 await apiFetch({
10 path: '/extendify/v1/agent/lock-post',
11 method: 'POST',
12 data: { postId },
13 }).catch(() => undefined);
14 // Send lock post signal every 2 minutes (must be under WP's 150s lock expiry)
15 timeoutId = setTimeout(lockPost, 2 * 60 * 1000);
16 };
17 lockPost();
18 return () => clearTimeout(timeoutId);
19 }, [postId, enabled]);
20 };
21