@@ -11,7 +11,10 @@ import {
1111} from '@wordpress/element'
1212import { models } from '@wordpress/api'
1313
14+ let isPolling = false
15+
1416const CimoDownloadNotice = props => {
17+ const { inMediaLibrary = false } = props
1518 const [ data , setData ] = useState ( { status : cimo ?. status , action : cimo ?. action } )
1619 const pollCountRef = useRef ( 0 )
1720
@@ -33,6 +36,12 @@ const CimoDownloadNotice = props => {
3336
3437 // Polls the Cimo plugin status to detect installation or activation state changes
3538 const pollStatus = ( action , link , pollOnce = false ) => {
39+ if ( isPolling ) {
40+ return
41+ }
42+
43+ isPolling = true
44+
3645 fetch ( ajaxUrl , {
3746 method : 'POST' ,
3847 headers : { 'Content-Type' : 'application/x-www-form-urlencoded' } ,
@@ -76,6 +85,7 @@ const CimoDownloadNotice = props => {
7685 ( action === 'install' && ( _data . status === 'installed' || _data . status === 'activated' ) ) ||
7786 ( action === 'activate' && _data . status === 'activated' )
7887 ) {
88+ isPolling = false
7989 return
8090 }
8191
@@ -89,6 +99,10 @@ const CimoDownloadNotice = props => {
8999 }
90100
91101 useEffect ( ( ) => {
102+ if ( inMediaLibrary ) {
103+ return
104+ }
105+
92106 const _media = wp . media
93107 const old = _media . view . MediaFrame . Select
94108
@@ -186,7 +200,7 @@ domReady( () => {
186200 }
187201 }
188202
189- createRoot ( noticeDiv ) . render ( < CimoDownloadNotice onDismiss = { onDismiss } /> )
203+ createRoot ( noticeDiv ) . render ( < CimoDownloadNotice onDismiss = { onDismiss } inMediaLibrary = { true } /> )
190204 details . insertAdjacentElement ( 'afterend' , noticeDiv )
191205 }
192206
0 commit comments