| 1 |
import apiFetch from '@wordpress/api-fetch'; |
| 2 |
|
| 3 |
// The feed has no positive marker for a publish CTA, only this trigger. |
| 4 |
export const publishesSite = (notification) => |
| 5 |
notification?.trigger === 'unpublished'; |
| 6 |
|
| 7 |
export const publishSite = () => |
| 8 |
apiFetch({ |
| 9 |
path: '/extendify/v1/site-visibility/publish', |
| 10 |
method: 'POST', |
| 11 |
}); |
| 12 |
|
| 13 |
export const publishAndReload = (onClick) => { |
| 14 |
onClick(); |
| 15 |
// Reload on failure too: the saved option decides visibility, not this click. |
| 16 |
return publishSite().finally(() => window.location.reload()); |
| 17 |
}; |
| 18 |
|