@@ -13,8 +13,8 @@ function formatBlock(n: number) {
1313 return `#${ n . toLocaleString ( ) } ` ;
1414}
1515
16- function timeAgo ( iso : string ) {
17- const diff = Math . floor ( ( Date . now ( ) - new Date ( iso ) . getTime ( ) ) / 1000 ) ;
16+ function timeAgo ( iso : string , now : number ) {
17+ const diff = Math . floor ( ( now - new Date ( iso ) . getTime ( ) ) / 1000 ) ;
1818 if ( diff < 60 ) return "just now" ;
1919 if ( diff < 3600 ) return `${ Math . floor ( diff / 60 ) } min ago` ;
2020 if ( diff < 86400 ) return `${ Math . floor ( diff / 3600 ) } h ago` ;
@@ -106,17 +106,17 @@ export function OverviewTopbar({
106106 lastUpdated,
107107} : OverviewTopbarProps ) {
108108 const { data : status } = useStatus ( ) ;
109- const { autoRefresh, setAutoRefresh, autoRefreshLabel } = useTopbar ( ) ;
109+ const { autoRefresh, setAutoRefresh, autoRefreshLabel, now } = useTopbar ( ) ;
110110
111111 const blockHeight = status ?. chainTip ? formatBlock ( status . chainTip ) : "—" ;
112112
113113 let lastUpdatedDisplay : string ;
114114 if ( lastUpdated === null ) {
115115 lastUpdatedDisplay = "—" ;
116116 } else if ( lastUpdated !== undefined ) {
117- lastUpdatedDisplay = timeAgo ( lastUpdated ) ;
117+ lastUpdatedDisplay = timeAgo ( lastUpdated , now ) ;
118118 } else {
119- lastUpdatedDisplay = status ?. timestamp ? timeAgo ( status . timestamp ) : "—" ;
119+ lastUpdatedDisplay = status ?. timestamp ? timeAgo ( status . timestamp , now ) : "—" ;
120120 }
121121
122122 return (
0 commit comments