Skip to content

Commit

Permalink
Merge pull request #2168 from blockscout/time-ago-noves-fix
Browse files Browse the repository at this point in the history
fix time ago
  • Loading branch information
isstuev authored Aug 14, 2024
2 parents 9c2e990 + 341756f commit fc0ee3b
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/hooks/useTimeAgoIncrement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function getUnits(diff: number) {
return [ DAY, 2 * DAY ];
}

function getUpdateParams(ts: string) {
function getUpdateParams(ts: string | number) {
const timeDiff = Date.now() - new Date(ts).getTime();
const [ unit, higherUnit ] = getUnits(timeDiff);

Expand All @@ -41,7 +41,7 @@ function getUpdateParams(ts: string) {
};
}

export default function useTimeAgoIncrement(ts: string | null, isEnabled?: boolean) {
export default function useTimeAgoIncrement(ts: string | number | null, isEnabled?: boolean) {
const [ value, setValue ] = React.useState(ts ? dayjs(ts).fromNow() : null);

React.useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const AddressAccountHistoryListItem = (props: Props) => {
</Text>
</Flex>
<TimeAgoWithTooltip
timestamp={ (props.tx.rawTransactionData.timestamp * 1000).toString() }
timestamp={ props.tx.rawTransactionData.timestamp * 1000 }
color="text_secondary"
borderRadius="sm"
fontWeight={ 500 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const AddressAccountHistoryTableItem = (props: Props) => {
<Tr>
<Td px={ 3 } py="18px" fontSize="sm" >
<TimeAgoWithTooltip
timestamp={ (props.tx.rawTransactionData.timestamp * 1000).toString() }
timestamp={ props.tx.rawTransactionData.timestamp * 1000 }
isLoading={ props.isPlaceholderData }
color="text_secondary"
borderRadius="sm"
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/TimeAgoWithTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import dayjs from 'lib/date/dayjs';
import useTimeAgoIncrement from 'lib/hooks/useTimeAgoIncrement';

type Props = {
timestamp?: string | null;
timestamp?: string | number | null;
fallbackText?: string;
isLoading?: boolean;
enableIncrement?: boolean;
Expand Down

0 comments on commit fc0ee3b

Please sign in to comment.