Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | 3x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x | import { __, _n, sprintf } from '@wordpress/i18n';
import { useMemo } from 'react';
import useProduct from '../../../data/products/use-product';
import { getMyJetpackWindowInitialState } from '../../../data/utils/get-my-jetpack-window-state';
import { timeSince } from '../../../utils/time-since';
export const useLastScanText = ( data: ProtectData ) => {
const slug = 'protect';
const { detail } = useProduct( slug );
const { isPluginActive = false } = detail || {};
const { plugins, themes } = getMyJetpackWindowInitialState();
const {
plugins: fromScanPlugins,
themes: fromScanThemes,
last_checked: lastScanTime = null,
last_scan_failed: lastScanFailed = false,
} = data?.scanData || {};
const pluginsCount = fromScanPlugins?.length || Object.keys( plugins ).length;
const themesCount = fromScanThemes?.length || Object.keys( themes ).length;
const timeSinceLastScan = lastScanTime ? timeSince( Date.parse( lastScanTime ) ) : false;
return useMemo( () => {
Eif ( isPluginActive ) {
if ( lastScanFailed ) {
return __( 'Last scan didn’t complete', 'jetpack-my-jetpack' );
}
Eif ( timeSinceLastScan ) {
return sprintf(
/* translators: %s is how long ago since the last scan took place, i.e.- "17 hours ago" */
__( 'Last scan: %s', 'jetpack-my-jetpack' ),
timeSinceLastScan
);
}
return null;
}
return (
sprintf(
/* translators: %d is the number of plugins installed on the site. */
_n( '%d plugin', '%d plugins', pluginsCount, 'jetpack-my-jetpack' ),
pluginsCount
) +
' ' +
/* translators: The ampersand symbol here (&) is meaning "and". */
__( '&', 'jetpack-my-jetpack' ) +
'\xa0' + // `\xa0` is a non-breaking space.
sprintf(
/* translators: %d is the number of themes installed on the site. */
_n( '%d theme', '%d themes', themesCount, 'jetpack-my-jetpack' ),
themesCount
).replace( ' ', '\xa0' ) // `\xa0` is a non-breaking space.
);
}, [ isPluginActive, lastScanFailed, timeSinceLastScan, pluginsCount, themesCount ] );
};
|