From ec86a30d6e9468f18f66c3455f34e965a2edc0fc Mon Sep 17 00:00:00 2001 From: Khushboo Mehta Date: Tue, 16 Jul 2024 13:30:48 +0200 Subject: [PATCH] fix(@desktop/wallet): Fix for Swap - Pay and Receive assets get unselected, Pay amount resets to 0 fixes #15525 --- storybook/qmlTests/tests/tst_SwapModal.qml | 6 +++--- ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml | 11 +++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/storybook/qmlTests/tests/tst_SwapModal.qml b/storybook/qmlTests/tests/tst_SwapModal.qml index 98be5c4964..9b2e24e672 100644 --- a/storybook/qmlTests/tests/tst_SwapModal.qml +++ b/storybook/qmlTests/tests/tst_SwapModal.qml @@ -932,10 +932,10 @@ Item { verify(!amountToSendInput.input.input.edit.cursorVisible) compare(amountToSendInput.input.placeholderText, LocaleUtils.numberToLocaleString(0)) compare(bottomItemText.text, root.swapAdaptor.currencyStore.formatCurrencyAmount(0, root.swapAdaptor.currencyStore.currentCurrency)) - compare(holdingSelector.currentTokensKey, "") - compare(tokenSelectorContentItemText.text, qsTr("Select asset")) + compare(holdingSelector.currentTokensKey, "STT") + compare(tokenSelectorContentItemText.text, "STT") verify(!maxTagButton.visible) - compare(receivePanel.selectedHoldingId, "") + compare(receivePanel.selectedHoldingId, "STT") compare(receivePanel.value, 0) compare(receivePanel.rawValue, "0") verify(!receivePanel.valueValid) diff --git a/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml b/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml index ca3710f1ee..952f3da9f6 100644 --- a/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml +++ b/ui/app/AppLayouts/Wallet/panels/SwapInputPanel.qml @@ -121,6 +121,17 @@ Control { } } + /* TODO: remove after https://github.com/status-im/status-desktop/issues/15604 is + implemented as this is hack to set token values correctly when model is reset */ + Connections { + target: holdingSelector.model + function onRowsInserted() { + if(!!tokenKey) { + root.reevaluateSelectedId() + } + } + } + background: Shape { id: shape