@@ -75,6 +75,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
7575 ) ;
7676
7777 const deletePost = useCallback ( async ( ) => {
78+ setLoading ( true ) ;
7879 if (
7980 ! ( await deleteDialog (
8081 'Are you sure you want to delete this post?' ,
@@ -129,6 +130,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
129130
130131 const schedule = useCallback (
131132 ( type : 'draft' | 'now' | 'schedule' ) => async ( ) => {
133+ setLoading ( true ) ;
132134 const checkAllValid = await ref . current . checkAllValid ( ) ;
133135 if ( type !== 'draft' ) {
134136 const notEnoughChars = checkAllValid . filter ( ( p : any ) => {
@@ -146,6 +148,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
146148 ' post is too short, it must be at least 6 characters' ,
147149 'warning'
148150 ) ;
151+ setLoading ( false ) ;
149152 item . preview ( ) ;
150153 return ;
151154 }
@@ -154,6 +157,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
154157 if ( item . valid === false ) {
155158 toaster . show ( 'Some fields are not valid' , 'warning' ) ;
156159 item . fix ( ) ;
160+ setLoading ( false ) ;
157161 return ;
158162 }
159163
@@ -165,6 +169,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
165169 'warning'
166170 ) ;
167171 item . preview ( ) ;
172+ setLoading ( false ) ;
168173 return ;
169174 }
170175 }
@@ -186,6 +191,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
186191 ) )
187192 ) {
188193 item . preview ( ) ;
194+ setLoading ( false ) ;
189195 return ;
190196 }
191197 }
@@ -304,6 +310,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
304310 onClick = { deletePost }
305311 className = "rounded-[4px] border-2 border-red-400 text-red-400"
306312 secondary = { true }
313+ disabled = { loading }
307314 >
308315 { t ( 'delete_post' , 'Delete Post' ) }
309316 </ Button >
@@ -314,7 +321,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
314321 onClick = { schedule ( 'draft' ) }
315322 className = "rounded-[4px] border-2 border-customColor21"
316323 secondary = { true }
317- disabled = { selectedIntegrations . length === 0 }
324+ disabled = { selectedIntegrations . length === 0 || loading }
318325 >
319326 { t ( 'save_as_draft' , 'Save as draft' ) }
320327 </ Button >
@@ -333,6 +340,7 @@ export const ManageModal: FC<AddEditModalProps> = (props) => {
333340 < Button
334341 className = "rounded-[4px] relative group"
335342 disabled = { selectedIntegrations . length === 0 || loading }
343+ loading = { loading }
336344 onClick = { schedule ( 'schedule' ) }
337345 >
338346 < div className = "flex justify-center items-center gap-[5px] h-full" >
0 commit comments