| 1 |
import {useSelect} from '@wordpress/data'; |
| 2 |
|
| 3 |
/** |
| 4 |
* @since 4.3.0 |
| 5 |
*/ |
| 6 |
export default function usePostState(): { isSaving: boolean, isDisabled: boolean } { |
| 7 |
const isSaving = useSelect((select) => { |
| 8 |
// @ts-ignore |
| 9 |
return select('core/editor').isSavingPost<boolean>(); |
| 10 |
}, []); |
| 11 |
|
| 12 |
const isDisabled = useSelect((select) => { |
| 13 |
// @ts-ignore |
| 14 |
return !select('core/editor').isEditedPostSaveable(); |
| 15 |
}, []); |
| 16 |
|
| 17 |
return { |
| 18 |
isSaving, |
| 19 |
isDisabled |
| 20 |
} |
| 21 |
} |
| 22 |
|