Skip to content

Commit

Permalink
update logic show step on sync info
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Oct 24, 2024
1 parent 6f0412a commit 6a081b7
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions ui/page/components/wallet_sync_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -323,34 +323,45 @@ func (wsi *WalletSyncInfo) syncContent(gtx C, uniform layout.Inset) D {
}
dp8 := values.MarginPadding8

currentSeconds := time.Now().Unix()
w := wsi.wallet
daysBehind := pageutils.TimeFormat(int(currentSeconds-w.GetBestBlockTimeStamp()), true)

totalStep := 2
if !wsi.isBtcOrLtcAsset() {
totalStep = 3
}
syncStep := 1
syncProgress1 := values.String(values.StrFetchingBlockHeaders)
syncProgressState := values.String(values.StrFetchingBlockHeaders)
syncProgress := values.String(values.StrWalletNotSynced)
if wsi.wallet.IsSyncing() {
if !wsi.isBtcOrLtcAsset() {
if isAddDiscovering {
syncStep = 2
syncProgress1 = values.String(values.StrAddressDiscovering)
syncProgressState = values.String(values.StrAddressDiscovering)
} else if syncIsScanning {
syncStep = 3
syncProgress1 = values.String(values.StrRescanningBlocks)
syncProgressState = values.String(values.StrRescanningBlocks)
}
}
syncProgress = values.StringF(values.StrSyncingProgressStat, daysBehind)
} else if wsi.wallet.IsRescanning() {
syncStep = 2
syncProgress1 = values.String(values.StrRescanningBlocks)
syncProgress = values.String(values.StrRescanningBlocks)
syncProgressState = values.String(values.StrRescanningBlocks)
} else if wsi.wallet.IsSynced() {
syncProgress1 = values.String(values.StrComplete)
syncProgress = values.String(values.StrComplete)
syncProgressState = values.String(values.StrComplete)
}

return uniform.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Horizontal}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return layout.Flex{Axis: layout.Vertical}.Layout(gtx,
layout.Rigid(func(gtx C) D {
if !isInProgress {
return D{}
}
return wsi.labelTexSize16Layout(values.StringF(values.StrSyncSteps, syncStep, totalStep), dp8, false)(gtx)
}),
layout.Rigid(wsi.labelTexSize16Layout(values.String(values.StrLatestBlock), dp8, true)),
Expand Down Expand Up @@ -384,7 +395,10 @@ func (wsi *WalletSyncInfo) syncContent(gtx C, uniform layout.Inset) D {
return layout.E.Layout(gtx, func(gtx C) D {
return layout.Flex{Axis: layout.Vertical, Alignment: layout.End}.Layout(gtx,
layout.Rigid(func(gtx C) D {
return wsi.labelTexSize16Layout(syncProgress1, dp8, false)(gtx)
if !isInProgress {
return D{}
}
return wsi.labelTexSize16Layout(syncProgressState, dp8, false)(gtx)
}),
layout.Rigid(func(gtx C) D {
latestBlockTitle := fmt.Sprintf("%d (%s)", bestBlock.Height, pageutils.TimeAgo(bestBlock.Timestamp))
Expand All @@ -404,15 +418,6 @@ func (wsi *WalletSyncInfo) syncContent(gtx C, uniform layout.Inset) D {
return wsi.labelTexSize16Layout(blockHeightFetched, dp8, false)(gtx)
}),
layout.Rigid(func(gtx C) D {
currentSeconds := time.Now().Unix()
w := wsi.wallet
daysBehind := pageutils.TimeFormat(int(currentSeconds-w.GetBestBlockTimeStamp()), true)

syncProgress := values.String(values.StrWalletNotSynced)
if wsi.wallet.IsSyncing() {
syncProgress = values.StringF(values.StrSyncingProgressStat, daysBehind)
}

return wsi.labelTexSize16Layout(syncProgress, dp8, false)(gtx)
}),
layout.Rigid(func(gtx C) D {
Expand Down

0 comments on commit 6a081b7

Please sign in to comment.