fix(@desktop/wallet): Fix for Token details view showing Dummy data.

This commit is contained in:
Khushboo Mehta 2023-12-08 19:41:12 +05:30 committed by Khushboo-dev-cpp
parent d587552c40
commit 9a0ce98d1b
3 changed files with 19 additions and 14 deletions

View File

@ -54,9 +54,9 @@ Item {
width: parent.width
asset.name: token && token.symbol ? Style.png("tokens/%1".arg(token.symbol)) : ""
asset.isImage: true
primaryText: token.name ?? Constants.dummyText
secondaryText: token ? LocaleUtils.currencyAmountToLocaleString(token.enabledNetworkBalance) : Constants.dummyText
tertiaryText: token ? LocaleUtils.currencyAmountToLocaleString(token.enabledNetworkCurrencyBalance) : Constants.dummyText
primaryText: token && token.name ? token.name : Constants.dummyText
secondaryText: token && token.enabledNetworkBalance ? LocaleUtils.currencyAmountToLocaleString(token.enabledNetworkBalance) : Constants.dummyText
tertiaryText: token && token.enabledNetworkCurrencyBalance ? LocaleUtils.currencyAmountToLocaleString(token.enabledNetworkCurrencyBalance) : Constants.dummyText
balances: token && token.balances ? token.balances : null
networksModel: RootStore.allNetworks
isLoading: root.assetsLoading
@ -328,7 +328,7 @@ Item {
Layout.fillWidth: true
}
InformationTile {
readonly property double changePctHour: token.changePctHour ?? 0
readonly property double changePctHour: token && token.changePctHour ? token.changePctHour : 0
maxWidth: parent.width
primaryText: qsTr("Hour")
secondaryText: "%1%".arg(LocaleUtils.numberToLocaleString(changePctHour, 2))
@ -338,7 +338,7 @@ Item {
isLoading: root.assetsLoading
}
InformationTile {
readonly property double changePctDay: token.changePctDay ?? 0
readonly property double changePctDay: token && token.changePctDay ? token.changePctDay : 0
maxWidth: parent.width
primaryText: qsTr("Day")
secondaryText: "%1%".arg(LocaleUtils.numberToLocaleString(changePctDay, 2))
@ -348,7 +348,7 @@ Item {
isLoading: root.assetsLoading
}
InformationTile {
readonly property double changePct24hour: token.changePct24hour ?? 0
readonly property double changePct24hour: token && token.changePct24hour ? token.changePct24hour : 0
maxWidth: parent.width
primaryText: qsTr("24 Hours")
secondaryText: "%1%".arg(LocaleUtils.numberToLocaleString(changePct24hour, 2))
@ -396,7 +396,7 @@ Item {
font.pixelSize: 15
lineHeight: 22
lineHeightMode: Text.FixedHeight
text: token.description ?? Constants.dummyText
text: token && token.description ? token.description : Constants.dummyText
customColor: Theme.palette.directColor1
elide: Text.ElideRight
wrapMode: Text.Wrap
@ -438,7 +438,7 @@ Item {
return networkIconUrl ? Style.svg("tiny/" + networkIconUrl) : ""
}
tagPrimaryLabel.text: token && token.builtOn !== "" ? RootStore.getNetworkName(token.builtOn) : "---"
tagSecondaryLabel.text: token.address ?? "---"
tagSecondaryLabel.text: token && token.address ? token.address : "---"
visible: typeof token != "undefined" && token && token.builtOn !== "" && token.address !== ""
customBackground: Component {
Rectangle {

View File

@ -76,6 +76,8 @@ Control {
loading: root.isLoading
}
}
/* TODO :: Issue with not being able to see correct balnces after switching assets will be fixed under
https://github.com/status-im/status-desktop/issues/12912 */
Row {
spacing: Style.current.smallPadding
anchors.left: parent.left

View File

@ -161,7 +161,7 @@ StatusScrollView {
id: delegateLoader
Loader {
property var modelData: model
property int index: index
property int delegateIndex: index
width: ListView.view.width
sourceComponent: model.loading ? loadingTokenDelegate: tokenDelegate
}
@ -170,7 +170,7 @@ StatusScrollView {
Component {
id: loadingTokenDelegate
LoadingTokenDelegate {
objectName: "AssetView_LoadingTokenDelegate_" + index
objectName: "AssetView_LoadingTokenDelegate_" + delegateIndex
}
}
@ -195,8 +195,9 @@ StatusScrollView {
onClicked: (itemId, mouse) => {
if (mouse.button === Qt.LeftButton) {
RootStore.getHistoricalDataForToken(modelData.symbol, RootStore.currencyStore.currentCurrency)
d.selectedAssetIndex = index
assetClicked(modelData)
d.selectedAssetIndex = delegateIndex
let selectedModel = !!modelData.communityId ? d.communityAssetsModel: d.regularAssetsModel
assetClicked(selectedModel.get(delegateIndex))
} else if (mouse.button === Qt.RightButton) {
Global.openMenu(tokenContextMenu, this,
{symbol: modelData.symbol, assetName: modelData.name, assetImage: symbolUrl,
@ -206,8 +207,10 @@ StatusScrollView {
onSwitchToCommunityRequested: root.switchToCommunityRequested(communityId)
Component.onCompleted: {
// on Model reset if the detail view is shown, update the data in background.
if(root.assetDetailsLaunched && index === d.selectedAssetIndex)
assetClicked(modelData)
if(root.assetDetailsLaunched && delegateIndex === d.selectedAssetIndex) {
let selectedModel = !!modelData.communityId ? d.communityAssetsModel: d.regularAssetsModel
assetClicked(selectedModel.get(delegateIndex))
}
}
}
}