+
{t('network-status.tooltip.start-block-number')}:
{localNumberFormatter(startBlockNumber)}
) : null}
+
+
{t('network-status.left-time')}
+
{getSyncLeftTime(estimate)}
+
{isLightClient && (
void
startBlockNumber?: string
+ estimate?: number
}>) => {
const [t] = useTranslation()
const [isOpen, setIsOpen] = useState(false)
@@ -127,6 +135,7 @@ const SyncStatus = ({
isLightClient={isLightClient}
onOpenSetStartBlock={onOpenSetStartBlock}
startBlockNumber={startBlockNumber}
+ estimate={estimate}
/>
}
trigger="click"
diff --git a/packages/neuron-ui/src/components/SyncStatus/syncStatus.module.scss b/packages/neuron-ui/src/components/SyncStatus/syncStatus.module.scss
index 9afd0e19e6..0392091b75 100755
--- a/packages/neuron-ui/src/components/SyncStatus/syncStatus.module.scss
+++ b/packages/neuron-ui/src/components/SyncStatus/syncStatus.module.scss
@@ -46,6 +46,8 @@
.tipContainer {
.tip {
padding: 12px;
+ // set left 40% to avoid horizontal scroll bar when find valid target
+ left: 40% !important;
}
.blockSynced {
font-size: 12px;
@@ -92,7 +94,7 @@
}
}
- .startBlockNumber {
+ .item {
margin-top: 8px;
.title {
font-size: 12px;
diff --git a/packages/neuron-ui/src/locales/en.json b/packages/neuron-ui/src/locales/en.json
index 338f714db6..c16a08204d 100644
--- a/packages/neuron-ui/src/locales/en.json
+++ b/packages/neuron-ui/src/locales/en.json
@@ -35,7 +35,8 @@
"start-block-number": "Start block number",
"set-start-block-number": "Set start block number"
},
- "migrating": "migrating..."
+ "migrating": "migrating...",
+ "left-time": "Left Time"
},
"import-hardware": {
"title": {
diff --git a/packages/neuron-ui/src/locales/es.json b/packages/neuron-ui/src/locales/es.json
index 9909598ea0..e8a8b80408 100644
--- a/packages/neuron-ui/src/locales/es.json
+++ b/packages/neuron-ui/src/locales/es.json
@@ -34,7 +34,8 @@
"looking-valid-target": "Buscando objetivo válido asumido",
"set-start-block-number": "Establecer el número de bloque inicial"
},
- "migrating": "migrando..."
+ "migrating": "migrando...",
+ "left-time": "Tiempo restante"
},
"import-hardware": {
"title": {
diff --git a/packages/neuron-ui/src/locales/fr.json b/packages/neuron-ui/src/locales/fr.json
index a4fcb7e2c9..02e4fd1cc2 100644
--- a/packages/neuron-ui/src/locales/fr.json
+++ b/packages/neuron-ui/src/locales/fr.json
@@ -35,7 +35,8 @@
"start-block-number": "bloc de départ",
"set-start-block-number": "Définir le numéro de bloc de départ"
},
- "migrating": "migration en cours..."
+ "migrating": "migration en cours...",
+ "left-time": "Temps restant"
},
"import-hardware": {
"title": {
diff --git a/packages/neuron-ui/src/locales/zh-tw.json b/packages/neuron-ui/src/locales/zh-tw.json
index 151d07d7dd..c953a9676b 100644
--- a/packages/neuron-ui/src/locales/zh-tw.json
+++ b/packages/neuron-ui/src/locales/zh-tw.json
@@ -35,7 +35,8 @@
"start-block-number": "起始區塊",
"set-start-block-number": "設置同步起始區塊"
},
- "migrating": "正在數據遷移..."
+ "migrating": "正在數據遷移...",
+ "left-time": "剩余時間"
},
"import-hardware": {
"title": {
diff --git a/packages/neuron-ui/src/locales/zh.json b/packages/neuron-ui/src/locales/zh.json
index 05fdaf61bd..88b3e02af7 100644
--- a/packages/neuron-ui/src/locales/zh.json
+++ b/packages/neuron-ui/src/locales/zh.json
@@ -35,7 +35,8 @@
"start-block-number": "起始区块",
"set-start-block-number": "设置同步起始区块"
},
- "migrating": "正在数据迁移..."
+ "migrating": "正在数据迁移...",
+ "left-time": "剩余时间"
},
"import-hardware": {
"title": {
diff --git a/packages/neuron-ui/src/tests/getSyncLeftTime/fixtures.json b/packages/neuron-ui/src/tests/getSyncLeftTime/fixtures.json
index b677363a57..85cc88cb20 100644
--- a/packages/neuron-ui/src/tests/getSyncLeftTime/fixtures.json
+++ b/packages/neuron-ui/src/tests/getSyncLeftTime/fixtures.json
@@ -3,20 +3,32 @@
"estimate": null,
"expected": "-"
},
- "should return 00:01 when estimate is 60_000": {
+ "should return 00:00:00 when estimate is less than 1_000": {
+ "estimate": 999,
+ "expected": "00:00:00"
+ },
+ "should return 00:00:01 when estimate is 1_000": {
+ "estimate": 1000,
+ "expected": "00:00:01"
+ },
+ "should return 00:01:00 when estimate is 60_000": {
"estimate": 60000,
- "expected": "00:01"
+ "expected": "00:01:00"
+ },
+ "should return 00:01:59 when estimate is 119_999": {
+ "estimate": 119999,
+ "expected": "00:01:59"
},
"should return 01:00 when estimate is 60 * 60_000": {
"estimate": 3600000,
- "expected": "01:00"
+ "expected": "01:00:00"
},
- "should return 00:00 when estimate is less than 30_000": {
- "estimate": 29999,
- "expected": "00:00"
+ "should return 01:59:59 when estimate is 60 * 60_000 + 59 * 60_000 + 59 * 1_000": {
+ "estimate": 7199000,
+ "expected": "01:59:59"
},
"should return 00:01 when estimate is less than 60_000 but greater than 30_000": {
"estimate": 30001,
- "expected": "00:01"
+ "expected": "00:00:30"
}
}
diff --git a/packages/neuron-ui/src/utils/getSyncLeftTime.ts b/packages/neuron-ui/src/utils/getSyncLeftTime.ts
index c717f0a300..9b45a9f274 100644
--- a/packages/neuron-ui/src/utils/getSyncLeftTime.ts
+++ b/packages/neuron-ui/src/utils/getSyncLeftTime.ts
@@ -1,4 +1,5 @@
-const MINS_PER_HOUR = 60
+const MILLISECS_PER_SEC = 1_000
+const MILLISECS_PER_MIN = 60_000
const MILLISECS_PER_HOUR = 3600_000
export const getSyncLeftTime = (estimate: number | undefined) => {
@@ -6,8 +7,9 @@ export const getSyncLeftTime = (estimate: number | undefined) => {
if (typeof estimate === 'number') {
const time = estimate / MILLISECS_PER_HOUR
const hrs = Math.floor(time)
- const mins = Math.round((time - hrs) * MINS_PER_HOUR)
- leftTime = `${hrs.toString().padStart(2, '0')}:${mins.toString().padStart(2, '0')}`
+ const mins = Math.floor((estimate - hrs * MILLISECS_PER_HOUR) / MILLISECS_PER_MIN)
+ const secs = Math.floor((estimate - hrs * MILLISECS_PER_HOUR - mins * MILLISECS_PER_MIN) / MILLISECS_PER_SEC)
+ leftTime = [hrs, mins, secs].map(v => v.toString().padStart(2, '0')).join(':')
}
return leftTime
}