From 34fd4fc81488c4f1809f9dbc1bcb1a84843e4dcd Mon Sep 17 00:00:00 2001 From: Stefan Date: Wed, 10 Apr 2024 22:38:15 +0300 Subject: [PATCH] fix(wallet): update wallet assets and collectibles order on user action Add a specific state to the saveSettings action to update the model by reloading the data. The previous implementation was using the same save address which doesn't update. Either in the past there was a side effect that made it work or it was never working. Closes #14365 --- storybook/pages/ManageAssetsPanelPage.qml | 2 +- storybook/pages/ManageCollectiblesPanelPage.qml | 2 +- storybook/qmlTests/tests/tst_ManageCollectiblesPanel.qml | 2 +- ui/app/AppLayouts/Profile/views/WalletView.qml | 4 ++-- ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml | 4 ++-- ui/app/AppLayouts/Wallet/panels/ManageAssetsPanel.qml | 5 ++++- ui/app/AppLayouts/Wallet/panels/ManageCollectiblesPanel.qml | 5 ++++- 7 files changed, 15 insertions(+), 9 deletions(-) diff --git a/storybook/pages/ManageAssetsPanelPage.qml b/storybook/pages/ManageAssetsPanelPage.qml index ecda3c610c..01965a5264 100644 --- a/storybook/pages/ManageAssetsPanelPage.qml +++ b/storybook/pages/ManageAssetsPanelPage.qml @@ -80,7 +80,7 @@ SplitView { Button { enabled: showcasePanel.dirty text: "Save" - onClicked: showcasePanel.saveSettings() + onClicked: showcasePanel.saveSettings(false /* update */) } Button { diff --git a/storybook/pages/ManageCollectiblesPanelPage.qml b/storybook/pages/ManageCollectiblesPanelPage.qml index a513ccffdf..3c8eef3cfd 100644 --- a/storybook/pages/ManageCollectiblesPanelPage.qml +++ b/storybook/pages/ManageCollectiblesPanelPage.qml @@ -74,7 +74,7 @@ SplitView { Button { enabled: showcasePanel.dirty text: "Save" - onClicked: showcasePanel.saveSettings() + onClicked: showcasePanel.saveSettings(false /* update */) } Button { diff --git a/storybook/qmlTests/tests/tst_ManageCollectiblesPanel.qml b/storybook/qmlTests/tests/tst_ManageCollectiblesPanel.qml index 3c1b7353e0..52acb233e3 100644 --- a/storybook/qmlTests/tests/tst_ManageCollectiblesPanel.qml +++ b/storybook/qmlTests/tests/tst_ManageCollectiblesPanel.qml @@ -357,7 +357,7 @@ Item { // save verify(controlUnderTest.dirty) - controlUnderTest.saveSettings() + controlUnderTest.saveSettings(false /* update */) verify(!controlUnderTest.dirty) // load the settings and check BigKitty is still on top diff --git a/ui/app/AppLayouts/Profile/views/WalletView.qml b/ui/app/AppLayouts/Profile/views/WalletView.qml index c74dbec65c..c89d62d353 100644 --- a/ui/app/AppLayouts/Profile/views/WalletView.qml +++ b/ui/app/AppLayouts/Profile/views/WalletView.qml @@ -68,10 +68,10 @@ SettingsContentBase { toast.changesDetectedText: manageTokensView.advancedTabVisible ? toast.defaultChangesDetectedText : qsTr("New custom sort order created") onSaveForLaterClicked: { - manageTokensView.saveChanges() + manageTokensView.saveChanges(false /* update */) } onSaveChangesClicked: { - manageTokensView.saveChanges() + manageTokensView.saveChanges(true /* update */) if (manageTokensView.advancedTabVisible) { // don't emit toasts when the Advanced tab is visible diff --git a/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml b/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml index 9a21be4696..29ee824262 100644 --- a/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml +++ b/ui/app/AppLayouts/Profile/views/wallet/ManageTokensView.qml @@ -42,8 +42,8 @@ Item { readonly property bool dirty: !!loader.item && loader.item.dirty readonly property bool advancedTabVisible: tabBar.currentIndex === d.advancedTabIndex - function saveChanges() { - loader.item.saveSettings() + function saveChanges(update) { + loader.item.saveSettings(update) } function resetChanges() { diff --git a/ui/app/AppLayouts/Wallet/panels/ManageAssetsPanel.qml b/ui/app/AppLayouts/Wallet/panels/ManageAssetsPanel.qml index 5fa30645c6..74b40fa435 100644 --- a/ui/app/AppLayouts/Wallet/panels/ManageAssetsPanel.qml +++ b/ui/app/AppLayouts/Wallet/panels/ManageAssetsPanel.qml @@ -21,9 +21,12 @@ DoubleFlickableWithFolding { property var getCurrencyAmount: function (balance, symbol) {} property var getCurrentCurrencyAmount: function(balance) {} - function saveSettings() { + function saveSettings(update) { let jsonSettings = root.controller.serializeSettingsAsJson() root.controller.requestSaveSettings(jsonSettings); + if(update) { + root.controller.requestLoadSettings(); + } } function revert() { diff --git a/ui/app/AppLayouts/Wallet/panels/ManageCollectiblesPanel.qml b/ui/app/AppLayouts/Wallet/panels/ManageCollectiblesPanel.qml index f05dd521f9..3d58aece8c 100644 --- a/ui/app/AppLayouts/Wallet/panels/ManageCollectiblesPanel.qml +++ b/ui/app/AppLayouts/Wallet/panels/ManageCollectiblesPanel.qml @@ -18,9 +18,12 @@ DoubleFlickableWithFolding { readonly property bool dirty: root.controller.dirty readonly property bool hasSettings: root.controller.hasSettings - function saveSettings() { + function saveSettings(update) { let jsonSettings = root.controller.serializeSettingsAsJson() root.controller.requestSaveSettings(jsonSettings) + if(update) { + root.controller.requestLoadSettings(); + } } function revert() {