Commit fd2176d9 authored by tom's avatar tom

improve progress circle

parent ea5b1aae
...@@ -27,7 +27,7 @@ const GasInfoTooltipContent = ({ data, dataUpdatedAt }: Props) => { ...@@ -27,7 +27,7 @@ const GasInfoTooltipContent = ({ data, dataUpdatedAt }: Props) => {
<GridItem color="text_secondary" display="flex" justifyContent="flex-end" columnGap={ 2 }> <GridItem color="text_secondary" display="flex" justifyContent="flex-end" columnGap={ 2 }>
{ dayjs(data.gas_price_updated_at).format('MMM DD, HH:mm:ss') } { dayjs(data.gas_price_updated_at).format('MMM DD, HH:mm:ss') }
{ data.gas_prices_update_in !== 0 && { data.gas_prices_update_in !== 0 &&
<GasInfoUpdateTimer startTime={ dataUpdatedAt } duration={ data.gas_prices_update_in }/> } <GasInfoUpdateTimer key={ dataUpdatedAt } startTime={ dataUpdatedAt } duration={ data.gas_prices_update_in }/> }
</GridItem> </GridItem>
</> </>
) } ) }
......
import { CircularProgress } from '@chakra-ui/react'; import { CircularProgress } from '@chakra-ui/react';
import React from 'react'; import React from 'react';
import { SECOND } from 'lib/consts';
import dayjs from 'lib/date/dayjs'; import dayjs from 'lib/date/dayjs';
interface Props { interface Props {
...@@ -14,8 +13,8 @@ const getValue = (startDate: dayjs.Dayjs, duration: number) => { ...@@ -14,8 +13,8 @@ const getValue = (startDate: dayjs.Dayjs, duration: number) => {
const diff = now.diff(startDate, 'ms'); const diff = now.diff(startDate, 'ms');
const value = diff / duration * 100; const value = diff / duration * 100;
if (value >= 95) { if (value >= 99) {
return 95; return 99;
} }
return value; return value;
...@@ -30,10 +29,10 @@ const GasInfoUpdateTimer = ({ startTime, duration }: Props) => { ...@@ -30,10 +29,10 @@ const GasInfoUpdateTimer = ({ startTime, duration }: Props) => {
const intervalId = window.setInterval(() => { const intervalId = window.setInterval(() => {
const nextValue = getValue(startDate, duration); const nextValue = getValue(startDate, duration);
setValue(nextValue); setValue(nextValue);
if (nextValue === 95) { if (nextValue === 99) {
window.clearInterval(intervalId); window.clearInterval(intervalId);
} }
}, SECOND); }, 100);
return () => { return () => {
window.clearInterval(intervalId); window.clearInterval(intervalId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment