From 6f0412a4bbb79961a2ed0f885383af0097c5a9cf Mon Sep 17 00:00:00 2001 From: Jusitn Do Date: Fri, 18 Oct 2024 22:24:14 +0700 Subject: [PATCH 1/2] update sync info --- ui/page/components/wallet_sync_info.go | 41 +++++++++++++++++++------- ui/values/localizable/en.go | 4 +-- 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/ui/page/components/wallet_sync_info.go b/ui/page/components/wallet_sync_info.go index 30f1518c4..d732112f6 100644 --- a/ui/page/components/wallet_sync_info.go +++ b/ui/page/components/wallet_sync_info.go @@ -322,10 +322,37 @@ func (wsi *WalletSyncInfo) syncContent(gtx C, uniform layout.Inset) D { syncIsScanning = wsi.wallet.(*dcr.Asset).IsSycnRescanning() } dp8 := values.MarginPadding8 + + totalStep := 2 + if !wsi.isBtcOrLtcAsset() { + totalStep = 3 + } + syncStep := 1 + syncProgress1 := values.String(values.StrFetchingBlockHeaders) + if wsi.wallet.IsSyncing() { + if !wsi.isBtcOrLtcAsset() { + if isAddDiscovering { + syncStep = 2 + syncProgress1 = values.String(values.StrAddressDiscovering) + } else if syncIsScanning { + syncStep = 3 + syncProgress1 = values.String(values.StrRescanningBlocks) + } + } + } else if wsi.wallet.IsRescanning() { + syncStep = 2 + syncProgress1 = values.String(values.StrRescanningBlocks) + } else if wsi.wallet.IsSynced() { + syncProgress1 = 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 { + return wsi.labelTexSize16Layout(values.StringF(values.StrSyncSteps, syncStep, totalStep), dp8, false)(gtx) + }), layout.Rigid(wsi.labelTexSize16Layout(values.String(values.StrLatestBlock), dp8, true)), layout.Rigid(func(gtx C) D { if !isInProgress { @@ -356,6 +383,9 @@ func (wsi *WalletSyncInfo) syncContent(gtx C, uniform layout.Inset) D { layout.Flexed(1, func(gtx C) 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) + }), layout.Rigid(func(gtx C) D { latestBlockTitle := fmt.Sprintf("%d (%s)", bestBlock.Height, pageutils.TimeAgo(bestBlock.Timestamp)) return wsi.labelTexSize16Layout(latestBlockTitle, dp8, false)(gtx) @@ -381,17 +411,6 @@ func (wsi *WalletSyncInfo) syncContent(gtx C, uniform layout.Inset) D { syncProgress := values.String(values.StrWalletNotSynced) if wsi.wallet.IsSyncing() { syncProgress = values.StringF(values.StrSyncingProgressStat, daysBehind) - if !wsi.isBtcOrLtcAsset() { - if isAddDiscovering { - syncProgress = values.String(values.StrAddressDiscovering) - } else if syncIsScanning { - syncProgress = values.String(values.StrRescanningBlocks) - } - } - } else if wsi.wallet.IsRescanning() { - syncProgress = values.String(values.StrRescanningBlocks) - } else if wsi.wallet.IsSynced() { - syncProgress = values.String(values.StrComplete) } return wsi.labelTexSize16Layout(syncProgress, dp8, false)(gtx) diff --git a/ui/values/localizable/en.go b/ui/values/localizable/en.go index 990a79dae..64bbf53e9 100644 --- a/ui/values/localizable/en.go +++ b/ui/values/localizable/en.go @@ -238,7 +238,7 @@ const EN = ` "feeRateAPI" = "Fee Rates API" "feerates" = "Fee Rates" "fetchingAgenda" = "Fetching agendas..." -"fetchingBlockHeaders" = "Fetching block headers ยท %v%%" +"fetchingBlockHeaders" = "Fetching block headers" "fetchingOrders" = "Fetching Orders" "fetchingPolicies" = "Fetching policies" "fetchingProposals" = "Fetching proposals..." @@ -615,7 +615,7 @@ const EN = ` "syncingProgress" = "Syncing progress" "syncingProgressStat" = "%s behind" "syncingState" = "Syncing..." -"syncSteps" = "Step %d/3" +"syncSteps" = "Step %d/%d" "takenAccount" = "Account name is taken" "tapToCopy" = "(Tap to copy)" "ticketVoted" = "A ticket just voted\nVote reward: %s DCR" From 6a081b7a19c65236491011751678a6d8ecfd02b1 Mon Sep 17 00:00:00 2001 From: Jusitn Do Date: Thu, 24 Oct 2024 22:08:08 +0700 Subject: [PATCH 2/2] update logic show step on sync info --- ui/page/components/wallet_sync_info.go | 35 +++++++++++++++----------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/ui/page/components/wallet_sync_info.go b/ui/page/components/wallet_sync_info.go index d732112f6..c8d006c27 100644 --- a/ui/page/components/wallet_sync_info.go +++ b/ui/page/components/wallet_sync_info.go @@ -323,27 +323,35 @@ 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 { @@ -351,6 +359,9 @@ func (wsi *WalletSyncInfo) syncContent(gtx C, uniform layout.Inset) D { 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)), @@ -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)) @@ -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 {