feat(wallet): implement reloadWalltet feature
implemented new reloadWalltet button and call reloadAccountTokens onClicked resolves: #13652
This commit is contained in:
parent
3e04967309
commit
c501319bd0
|
@ -119,4 +119,7 @@ method resetRpcStats*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method canProfileProveOwnershipOfProvidedAddresses*(self: AccessInterface, addresses: string): bool {.base.} =
|
method canProfileProveOwnershipOfProvidedAddresses*(self: AccessInterface, addresses: string): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method reloadWallet*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -283,8 +283,10 @@ method load*(self: Module) =
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
self.notifyFilterChanged()
|
self.notifyFilterChanged()
|
||||||
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args):
|
self.events.on(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT) do(e:Args):
|
||||||
|
let args = TokensPerAccountArgs(e)
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
self.notifyModulesBalanceIsLoaded()
|
self.notifyModulesBalanceIsLoaded()
|
||||||
|
self.view.emitTokensReloaded(args.timestamp)
|
||||||
self.events.on(SIGNAL_TOKENS_PRICES_UPDATED) do(e:Args):
|
self.events.on(SIGNAL_TOKENS_PRICES_UPDATED) do(e:Args):
|
||||||
self.setTotalCurrencyBalance()
|
self.setTotalCurrencyBalance()
|
||||||
self.notifyFilterChanged()
|
self.notifyFilterChanged()
|
||||||
|
@ -522,3 +524,6 @@ method canProfileProveOwnershipOfProvidedAddresses*(self: Module, addresses: str
|
||||||
if keypair.migratedToKeycard():
|
if keypair.migratedToKeycard():
|
||||||
return false
|
return false
|
||||||
return true
|
return true
|
||||||
|
|
||||||
|
method reloadWallet*(self: Module) =
|
||||||
|
self.walletAccountService.reloadAccountTokens()
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import NimQml, json
|
import NimQml, json
|
||||||
|
import times
|
||||||
|
|
||||||
import ./activity/controller as activityc
|
import ./activity/controller as activityc
|
||||||
import ./activity/details_controller as activity_detailsc
|
import ./activity/details_controller as activity_detailsc
|
||||||
|
@ -29,6 +30,7 @@ QtObject:
|
||||||
walletReady: bool
|
walletReady: bool
|
||||||
addressFilters: string
|
addressFilters: string
|
||||||
currentCurrency: string
|
currentCurrency: string
|
||||||
|
lastReloadTimestamp: string
|
||||||
|
|
||||||
proc setup(self: View) =
|
proc setup(self: View) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
@ -266,4 +268,36 @@ QtObject:
|
||||||
self.delegate.resetRpcStats()
|
self.delegate.resetRpcStats()
|
||||||
|
|
||||||
proc canProfileProveOwnershipOfProvidedAddresses*(self: View, addresses: string): bool {.slot.} =
|
proc canProfileProveOwnershipOfProvidedAddresses*(self: View, addresses: string): bool {.slot.} =
|
||||||
return self.delegate.canProfileProveOwnershipOfProvidedAddresses(addresses)
|
return self.delegate.canProfileProveOwnershipOfProvidedAddresses(addresses)
|
||||||
|
|
||||||
|
proc reloadWallet*(self: View) {.slot.} =
|
||||||
|
self.delegate.reloadWallet()
|
||||||
|
|
||||||
|
proc formatTime(timestamp: DateTime): string =
|
||||||
|
let now = now()
|
||||||
|
let diff = now - timestamp
|
||||||
|
|
||||||
|
# Calculate daysDiff directly within the if statement
|
||||||
|
if int(diff.inDays) == 0:
|
||||||
|
return timestamp.format("hh:mm tt") & " today"
|
||||||
|
elif int(diff.inDays) == 1:
|
||||||
|
return timestamp.format("hh:mm tt") & " yesterday"
|
||||||
|
else:
|
||||||
|
return timestamp.format("MMM d hh:mm tt")
|
||||||
|
|
||||||
|
|
||||||
|
proc lastReloadTimestampChanged*(self: View) {.signal.}
|
||||||
|
proc setLastReloadTimestamp*(self: View, lastReloadTimestamp: string) =
|
||||||
|
self.lastReloadTimestamp = lastReloadTimestamp
|
||||||
|
self.lastReloadTimestampChanged()
|
||||||
|
proc getLastReloadTimestamp(self: View): string {.slot.} =
|
||||||
|
return self.lastReloadTimestamp
|
||||||
|
QtProperty[string] lastReloadTimestamp:
|
||||||
|
read = getLastReloadTimestamp
|
||||||
|
notify = lastReloadTimestampChanged
|
||||||
|
|
||||||
|
|
||||||
|
proc tokensReloaded*(self: View) {.signal.}
|
||||||
|
proc emitTokensReloaded*(self: View, timestamp: DateTime) =
|
||||||
|
self.setLastReloadTimestamp(formatTime(timestamp))
|
||||||
|
self.tokensReloaded()
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
import times
|
||||||
|
|
||||||
# This method will group the account assets by symbol (in case of communiy, the token address)
|
# This method will group the account assets by symbol (in case of communiy, the token address)
|
||||||
proc onAllTokensBuilt*(self: Service, response: string) {.slot.} =
|
proc onAllTokensBuilt*(self: Service, response: string) {.slot.} =
|
||||||
var accountAddresses: seq[string] = @[]
|
var accountAddresses: seq[string] = @[]
|
||||||
var accountTokens: seq[GroupedTokenItem] = @[]
|
var accountTokens: seq[GroupedTokenItem] = @[]
|
||||||
defer: self.events.emit(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT, TokensPerAccountArgs(accountAddresses:accountAddresses, accountTokens: accountTokens))
|
defer:
|
||||||
|
let timestamp = now()
|
||||||
|
self.events.emit(SIGNAL_WALLET_ACCOUNT_TOKENS_REBUILT, TokensPerAccountArgs(accountAddresses:accountAddresses, accountTokens: accountTokens, timestamp: timestamp))
|
||||||
try:
|
try:
|
||||||
let responseObj = response.parseJson
|
let responseObj = response.parseJson
|
||||||
var storeResult: bool
|
var storeResult: bool
|
||||||
|
|
|
@ -72,6 +72,7 @@ type DerivedAddressesArgs* = ref object of Args
|
||||||
type TokensPerAccountArgs* = ref object of Args
|
type TokensPerAccountArgs* = ref object of Args
|
||||||
accountAddresses*: seq[string]
|
accountAddresses*: seq[string]
|
||||||
accountTokens*: seq[GroupedTokenItem]
|
accountTokens*: seq[GroupedTokenItem]
|
||||||
|
timestamp*: DateTime
|
||||||
|
|
||||||
type KeycardActivityArgs* = ref object of Args
|
type KeycardActivityArgs* = ref object of Args
|
||||||
success*: bool
|
success*: bool
|
||||||
|
|
|
@ -14,6 +14,7 @@ import SortFilterProxyModel 0.2
|
||||||
import utils 1.0
|
import utils 1.0
|
||||||
|
|
||||||
import "../controls"
|
import "../controls"
|
||||||
|
import "../stores"
|
||||||
|
|
||||||
Item {
|
Item {
|
||||||
id: root
|
id: root
|
||||||
|
@ -25,6 +26,7 @@ Item {
|
||||||
|
|
||||||
property alias headerButton: headerButton
|
property alias headerButton: headerButton
|
||||||
property alias networkFilter: networkFilter
|
property alias networkFilter: networkFilter
|
||||||
|
property alias reloadButton: reloadButton
|
||||||
|
|
||||||
signal buttonClicked()
|
signal buttonClicked()
|
||||||
|
|
||||||
|
@ -38,6 +40,8 @@ Item {
|
||||||
// account + balance
|
// account + balance
|
||||||
RowLayout {
|
RowLayout {
|
||||||
spacing: Style.current.halfPadding
|
spacing: Style.current.halfPadding
|
||||||
|
Layout.alignment: Qt.AlignLeft | Qt.AlignVCenter
|
||||||
|
|
||||||
StatusBaseText {
|
StatusBaseText {
|
||||||
objectName: "walletHeaderTitle"
|
objectName: "walletHeaderTitle"
|
||||||
Layout.alignment: Qt.AlignVCenter
|
Layout.alignment: Qt.AlignVCenter
|
||||||
|
@ -73,6 +77,74 @@ Item {
|
||||||
spacing: 16
|
spacing: 16
|
||||||
Layout.alignment: Qt.AlignTrailing
|
Layout.alignment: Qt.AlignTrailing
|
||||||
Layout.topMargin: 5
|
Layout.topMargin: 5
|
||||||
|
Component.onCompleted: console.info("bTest RowLayout width, height", width, height)
|
||||||
|
|
||||||
|
Row {
|
||||||
|
// Layout.fillWidth: true
|
||||||
|
Layout.alignment: Qt.AlignRight | Qt.AlignTop
|
||||||
|
Layout.preferredHeight: 38
|
||||||
|
spacing: 8
|
||||||
|
|
||||||
|
Component.onCompleted: console.info("bTest Row width, height", width, height)
|
||||||
|
// StatusButton {
|
||||||
|
// id: visiblityButton
|
||||||
|
// // spacing: 8
|
||||||
|
// size: StatusBaseButton.Size.Small
|
||||||
|
// borderColor: Theme.palette.directColor7
|
||||||
|
// borderWidth: 1
|
||||||
|
// normalColor: Theme.palette.transparent
|
||||||
|
// hoverColor: Theme.palette.baseColor2
|
||||||
|
|
||||||
|
// icon.name: "refresh"
|
||||||
|
// icon.height: 16
|
||||||
|
// icon.width: 16
|
||||||
|
// icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
||||||
|
// }
|
||||||
|
StatusButton {
|
||||||
|
id: reloadButton
|
||||||
|
size: StatusBaseButton.Size.Small
|
||||||
|
height: parent.height
|
||||||
|
width: height
|
||||||
|
borderColor: Theme.palette.directColor7
|
||||||
|
borderWidth: 1
|
||||||
|
|
||||||
|
normalColor: Theme.palette.transparent
|
||||||
|
hoverColor: Theme.palette.baseColor2
|
||||||
|
|
||||||
|
icon.name: "refresh"
|
||||||
|
icon.height: 16
|
||||||
|
icon.width: 16
|
||||||
|
icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
||||||
|
|
||||||
|
tooltip.text: "Last refreshed " + RootStore.walletSectionInst.lastReloadTimestamp
|
||||||
|
|
||||||
|
Connections {
|
||||||
|
target: RootStore.walletSectionInst
|
||||||
|
function onTokensReloaded() {
|
||||||
|
console.info("btest onTokensReloaded")
|
||||||
|
reloadButton.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onClicked: {
|
||||||
|
loading = true
|
||||||
|
RootStore.reloadWallet()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// StatusButton {
|
||||||
|
// id: thirdButton
|
||||||
|
// // spacing: 8
|
||||||
|
// size: StatusBaseButton.Size.Small
|
||||||
|
// borderColor: Theme.palette.directColor7
|
||||||
|
// borderWidth: 1
|
||||||
|
// normalColor: Theme.palette.transparent
|
||||||
|
// hoverColor: Theme.palette.baseColor2
|
||||||
|
|
||||||
|
// icon.name: "refresh"
|
||||||
|
// icon.height: 16
|
||||||
|
// icon.width: 16
|
||||||
|
// icon.color: hovered ? Theme.palette.directColor1 : Theme.palette.baseColor1
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
DAppsWorkflow {
|
DAppsWorkflow {
|
||||||
Layout.alignment: Qt.AlignTop
|
Layout.alignment: Qt.AlignTop
|
||||||
|
|
|
@ -558,4 +558,8 @@ QtObject {
|
||||||
const prefix = Constants.socialLinkPrefixesByType[Constants.socialLinkType.twitter]
|
const prefix = Constants.socialLinkPrefixesByType[Constants.socialLinkType.twitter]
|
||||||
return prefix + twitterHandle
|
return prefix + twitterHandle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function reloadWallet() {
|
||||||
|
walletSectionInst.reloadWallet()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue