1
- import { DaemonProfile , Label , Text } from '@siafoundation/design-system'
1
+ import { DaemonProfile , Label , Text , Link } from '@siafoundation/design-system'
2
2
import { useSyncStatus } from '../../hooks/useSyncStatus'
3
3
import {
4
4
useConsensusNetwork ,
5
+ useNodeState ,
5
6
useSyncerPeers ,
6
7
} from '@siafoundation/react-walletd'
7
8
import { useDialog } from '../../contexts/dialog'
9
+ import { humanTime } from '@siafoundation/units'
8
10
9
11
export function Profile ( ) {
10
12
const { openDialog } = useDialog ( )
11
13
const peers = useSyncerPeers ( )
12
14
const syncStatus = useSyncStatus ( )
13
15
const network = useConsensusNetwork ( )
16
+ const state = useNodeState ( {
17
+ config : {
18
+ swr : {
19
+ revalidateOnFocus : false ,
20
+ } ,
21
+ } ,
22
+ } )
23
+
24
+ const version = state . data ?. version
25
+ const versionUrl =
26
+ version === '?'
27
+ ? `https://github.com/SiaFoundation/walletd/commits/`
28
+ : version ?. match ( / ^ v \d + \. \d + \. \d + / )
29
+ ? `https://github.com/SiaFoundation/walletd/releases/${ version } `
30
+ : `https://github.com/SiaFoundation/walletd/tree/${ version } `
31
+
32
+ const uptime = state . data
33
+ ? new Date ( ) . getTime ( ) - new Date ( state . data ?. startTime ) . getTime ( )
34
+ : 0
35
+
14
36
return (
15
37
< DaemonProfile
16
38
name = "walletd"
@@ -23,6 +45,16 @@ export function Profile() {
23
45
firstTimeSyncing = { syncStatus . firstTimeSyncing }
24
46
moreThan100BlocksToSync = { syncStatus . moreThan100BlocksToSync }
25
47
>
48
+ { state . data && (
49
+ < div className = "flex gap-4 justify-between items-center" >
50
+ < Label size = "14" color = "subtle" noWrap className = "w-[100px]" >
51
+ Uptime
52
+ </ Label >
53
+ < div className = "flex-1 flex justify-end overflow-hidden -mr-0.5 pr-0.5" >
54
+ < Text size = "14" > { humanTime ( uptime , { format : 'long' } ) } </ Text >
55
+ </ div >
56
+ </ div >
57
+ ) }
26
58
{ network . data && (
27
59
< div className = "flex gap-4 justify-between items-center" >
28
60
< Label size = "14" color = "subtle" noWrap className = "w-[100px]" >
@@ -33,7 +65,7 @@ export function Profile() {
33
65
</ div >
34
66
</ div >
35
67
) }
36
- { /* <div className="flex gap-4 justify-between items-center">
68
+ < div className = "flex gap-4 justify-between items-center" >
37
69
< Label size = "14" color = "subtle" noWrap className = "w-[100px]" >
38
70
Version
39
71
</ Label >
@@ -46,7 +78,7 @@ export function Profile() {
46
78
>
47
79
{ state . data ?. version }
48
80
</ Link >
49
- </div> */ }
81
+ </ div >
50
82
</ DaemonProfile >
51
83
)
52
84
}
0 commit comments