Skip to content

Commit d52d5bf

Browse files
committed
revert unnecessary changes
1 parent 3c64268 commit d52d5bf

File tree

1 file changed

+22
-18
lines changed
  • client/my-sites/stats/stats-followers

1 file changed

+22
-18
lines changed

Diff for: client/my-sites/stats/stats-followers/index.jsx

+22-18
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { isEnabled } from '@automattic/calypso-config';
22
import { localizeUrl } from '@automattic/i18n-utils';
33
import clsx from 'clsx';
44
import { useTranslate } from 'i18n-calypso';
5+
import { useCallback } from 'react';
56
import { useSelector } from 'react-redux';
67
import isAtomicSite from 'calypso/state/selectors/is-site-wpcom-atomic';
78
import { getSiteSlug, isAdminInterfaceWPAdmin, isJetpackSite } from 'calypso/state/sites/selectors';
@@ -26,28 +27,31 @@ const StatModuleFollowers = ( { className } ) => {
2627

2728
const { data: subTotals, isLoading, isError: hasError } = useSubscribersTotalsQueries( siteId );
2829

29-
const calculateOffset = ( pastValue ) => {
30-
const now = new Date();
31-
const value = new Date( pastValue );
32-
const difference = now.getTime() - value.getTime();
30+
const calculateOffset = useCallback(
31+
( pastValue ) => {
32+
const now = new Date();
33+
const value = new Date( pastValue );
34+
const difference = now.getTime() - value.getTime();
3335

34-
const seconds = Math.floor( difference / 1000 );
35-
const minutes = Math.ceil( seconds / 60 );
36-
const hours = Math.floor( minutes / 60 );
37-
const days = Math.floor( hours / 24 );
36+
const seconds = Math.floor( difference / 1000 );
37+
const minutes = Math.ceil( seconds / 60 );
38+
const hours = Math.floor( minutes / 60 );
39+
const days = Math.floor( hours / 24 );
3840

39-
let result = '';
41+
let result = '';
4042

41-
if ( days > 0 ) {
42-
result = translate( '%d days', { args: days } );
43-
} else if ( hours > 0 ) {
44-
result = translate( '%d hours', { args: hours } );
45-
} else if ( minutes > 0 ) {
46-
result = translate( '%d minutes', { args: minutes } );
47-
}
43+
if ( days > 0 ) {
44+
result = translate( '%d days', { args: days } );
45+
} else if ( hours > 0 ) {
46+
result = translate( '%d hours', { args: hours } );
47+
} else if ( minutes > 0 ) {
48+
result = translate( '%d minutes', { args: minutes } );
49+
}
4850

49-
return result;
50-
};
51+
return result;
52+
},
53+
[ translate ]
54+
);
5155

5256
const noData = ! subTotals.subscribers.length;
5357
const summaryPageSlug = siteSlug || '';

0 commit comments

Comments
 (0)