Fix regression where store age is 0 while isResolving for the option is returning false (https://github.com/woocommerce/woocommerce-admin/pull/5858)
Co-authored-by: Rebecca Scott <me@becdetat.com>
This commit is contained in:
parent
13a738558c
commit
88b64b6980
|
@ -178,6 +178,19 @@ CustomerEffortScoreTracks.propTypes = {
|
|||
createNotice: PropTypes.func,
|
||||
};
|
||||
|
||||
function getStoreAgeInWeeks( adminInstallTimestamp ) {
|
||||
if ( adminInstallTimestamp === 0 ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Date.now() is ms since Unix epoch, adminInstallTimestamp is in
|
||||
// seconds since Unix epoch.
|
||||
const storeAgeInMs = Date.now() - adminInstallTimestamp * 1000;
|
||||
const storeAgeInWeeks = Math.round( storeAgeInMs / WEEK );
|
||||
|
||||
return storeAgeInWeeks;
|
||||
}
|
||||
|
||||
export default compose(
|
||||
withSelect( ( select ) => {
|
||||
const { getOption, isResolving } = select( OPTIONS_STORE_NAME );
|
||||
|
@ -187,10 +200,7 @@ export default compose(
|
|||
|
||||
const adminInstallTimestamp =
|
||||
getOption( ADMIN_INSTALL_TIMESTAMP_OPTION_NAME ) || 0;
|
||||
// Date.now() is ms since Unix epoch, adminInstallTimestamp is in
|
||||
// seconds since Unix epoch.
|
||||
const storeAgeInMs = Date.now() - adminInstallTimestamp * 1000;
|
||||
const storeAgeInWeeks = Math.round( storeAgeInMs / WEEK );
|
||||
const storeAgeInWeeks = getStoreAgeInWeeks( adminInstallTimestamp );
|
||||
|
||||
const allowTrackingOption =
|
||||
getOption( ALLOW_TRACKING_OPTION_NAME ) || 'no';
|
||||
|
@ -198,6 +208,7 @@ export default compose(
|
|||
|
||||
const resolving =
|
||||
isResolving( 'getOption', [ SHOWN_FOR_ACTIONS_OPTION_NAME ] ) ||
|
||||
storeAgeInWeeks === null ||
|
||||
isResolving( 'getOption', [
|
||||
ADMIN_INSTALL_TIMESTAMP_OPTION_NAME,
|
||||
] ) ||
|
||||
|
|
Loading…
Reference in New Issue