Skip to content

Commit 3a72fc5

Browse files
committed
fix status
1 parent 9338467 commit 3a72fc5

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

src/lazy-components/cimo/index.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ import {
1111
} from '@wordpress/element'
1212
import { models } from '@wordpress/api'
1313

14+
let isPolling = false
15+
1416
const 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

src/lazy-components/cimo/style.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
background: none;
1313
border: none;
1414
height: 14px;
15-
width: 14px;
1615
position: absolute;
1716
right: 4px;
1817
top: 4px;

src/welcome/useful-plugins.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,10 @@ function check_cimo_status() {
287287
wp_clean_plugins_cache();
288288

289289
if ( $action === 'install' && ! self::is_plugin_installed( $full_slug ) ) {
290-
$response[ 'status' ] = 'installing';
290+
$response[ 'status' ] = 'not_installed';
291291
} else if ( ! self::is_plugin_activated( $full_slug ) ) {
292-
$response[ 'status' ] = $action === 'install' ? 'installed' : 'activating';
292+
$response[ 'status' ] = 'installed';
293+
// If the plugin is installed and not activated, provide the action link to activate it
293294
$response[ 'action' ] = $action === 'install' ? html_entity_decode( wp_nonce_url(
294295
add_query_arg(
295296
[

0 commit comments

Comments
 (0)