Skip to content

Commit 252a00e

Browse files
authored
Merge pull request #836 from relayprotocol/joseph/fe-8003-capital-s-shown-when-transaction-that-take-2-minutes
Improved fill time display on success screen
2 parents 34b4833 + 2fcce34 commit 252a00e

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

.changeset/forty-bushes-fix.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@relayprotocol/relay-kit-ui': patch
3+
---
4+
5+
Improved fill time display on success screen

packages/ui/src/utils/relayTransaction.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { type Execute, RelayClient } from '@relayprotocol/relay-sdk'
22
import { type RelayTransaction } from '../types/index.js'
3-
import { relativeTime } from './time.js'
3+
import { formatSeconds } from './time.js'
44

55
export const extractFromChain = (
66
transaction?: RelayTransaction | null,
@@ -42,11 +42,7 @@ export const calculateFillTime = (transaction?: RelayTransaction | null) => {
4242
fillTime = '-'
4343
seconds = 0
4444
} else if (seconds > 60) {
45-
fillTime = `${relativeTime(
46-
txEndTimestamp * 1000,
47-
txStartTimestamp * 1000,
48-
true
49-
)}`
45+
fillTime = formatSeconds(seconds)
5046
} else {
5147
fillTime = `${seconds}s`
5248
}

packages/ui/src/utils/time.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ export const formatSeconds = (seconds: number): string => {
2020
const m = Math.floor((seconds % 3600) / 60)
2121
const s = Math.floor(seconds % 60)
2222

23-
const dDisplay = d > 0 ? d + (d == 1 ? ' d' : 'd ') : ''
24-
const hDisplay = h > 0 ? h + (h == 1 ? ' h' : 'h ') : ''
25-
const mDisplay = m > 0 ? m + (m == 1 ? ' m' : 'm ') : ''
26-
const sDisplay = s > 0 ? s + (s == 1 ? ' s' : 's ') : ''
27-
return `${dDisplay} ${hDisplay} ${mDisplay} ${sDisplay}`.trim()
23+
const parts: string[] = []
24+
if (d > 0) parts.push(`${d}d`)
25+
if (h > 0) parts.push(`${h}h`)
26+
if (m > 0) parts.push(`${m}m`)
27+
if (s > 0) parts.push(`${s}s`)
28+
29+
return parts.join(' ')
2830
}
2931

3032
export const get15MinuteInterval = () => {

0 commit comments

Comments
 (0)