From f5d1ece74b249c337953960b992978cedf109e8e Mon Sep 17 00:00:00 2001 From: Emil Sawicki Date: Fri, 22 Nov 2024 05:03:25 +0100 Subject: [PATCH] feat: Update store --- .../AppLayouts/Chat/popups/RequestPaymentModal.qml | 2 +- ui/app/AppLayouts/Chat/views/ChatColumnView.qml | 10 ++++++++++ .../controls/chat/ChatInputLinksPreviewArea.qml | 2 +- ui/imports/shared/status/StatusChatInput.qml | 5 +++++ ui/imports/shared/stores/RequestPaymentStore.qml | 12 ++++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/ui/app/AppLayouts/Chat/popups/RequestPaymentModal.qml b/ui/app/AppLayouts/Chat/popups/RequestPaymentModal.qml index 38739bf18b..ac16d36568 100644 --- a/ui/app/AppLayouts/Chat/popups/RequestPaymentModal.qml +++ b/ui/app/AppLayouts/Chat/popups/RequestPaymentModal.qml @@ -66,7 +66,7 @@ StatusDialog { readonly property var adaptor: TokenSelectorViewAdaptor { assetsModel: root.store.processedAssetsModel - flatNetworksModel: root.flatNetworksModel + flatNetworksModel: root.store.flatNetworksModel currentCurrency: root.store.currencyStore.currentCurrency plainTokensBySymbolModel: root.store.plainAssetsModel showAllTokens: true diff --git a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml index f2d6f5ff9e..641520ea6c 100644 --- a/ui/app/AppLayouts/Chat/views/ChatColumnView.qml +++ b/ui/app/AppLayouts/Chat/views/ChatColumnView.qml @@ -25,6 +25,7 @@ import AppLayouts.Communities.popups 1.0 import AppLayouts.Communities.panels 1.0 import AppLayouts.Profile.stores 1.0 as ProfileStores import AppLayouts.Chat.stores 1.0 as ChatStores +import AppLayouts.Wallet.stores 1.0 as WalletStore import "../helpers" import "../controls" @@ -294,6 +295,15 @@ Item { usersModel: d.activeUsersStore.usersModel sharedStore: root.sharedRootStore + requestPaymentStore: SharedStores.RequestPaymentStore { + currencyStore: root.rootStore.currencyStore + flatNetworksModel: WalletStore.RootStore.filteredFlatModel + processedAssetsModel: WalletStore.RootStore.walletAssetsStore.groupedAccountAssetsModel + plainAssetsModel: WalletStore.RootStore.tokensStore.plainTokensBySymbolModel + accountsModel: WalletStore.RootStore.nonWatchAccounts + + requestPaymentModel: !!d.activeChatContentModule ? d.activeChatContentModule.inputAreaModule.paymentRequestModel : null + } linkPreviewModel: !!d.activeChatContentModule ? d.activeChatContentModule.inputAreaModule.linkPreviewModel : null urlsList: d.urlsList diff --git a/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml b/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml index 9da7811cd7..af150cb7d8 100644 --- a/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml +++ b/ui/imports/shared/controls/chat/ChatInputLinksPreviewArea.qml @@ -34,7 +34,7 @@ Control { required property bool showLinkPreviewSettings readonly property alias hoveredUrl: d.hoveredUrl - readonly property bool hasContent: imagePreviewArray.length > 0 || showLinkPreviewSettings || linkPreviewRepeater.count > 0 + readonly property bool hasContent: imagePreviewArray.length > 0 || showLinkPreviewSettings || linkPreviewRepeater.count > 0 || requestPaymentRepeater.count > 0 signal imageRemoved(int index) signal imageClicked(var chatImage) diff --git a/ui/imports/shared/status/StatusChatInput.qml b/ui/imports/shared/status/StatusChatInput.qml index 9874572946..486a465f2b 100644 --- a/ui/imports/shared/status/StatusChatInput.qml +++ b/ui/imports/shared/status/StatusChatInput.qml @@ -1021,7 +1021,12 @@ Rectangle { onAccepted: { control.requestPaymentStore.addPaymentRequest(selectedTokenKey, amount, selectedAccountAddress, selectedNetworkChainId) + destroy() } + + onRejected: destroy() + + Component.onCompleted: d.requestPaymentPopup = null } } diff --git a/ui/imports/shared/stores/RequestPaymentStore.qml b/ui/imports/shared/stores/RequestPaymentStore.qml index c169ffe4d9..b91582deb8 100644 --- a/ui/imports/shared/stores/RequestPaymentStore.qml +++ b/ui/imports/shared/stores/RequestPaymentStore.qml @@ -6,4 +6,16 @@ QtObject { required property var processedAssetsModel required property var plainAssetsModel required property var accountsModel + + property var requestPaymentModel: null + + function addPaymentRequest(symbol, amount, address, chainId) { + if (!requestPaymentModel) + return + requestPaymentModel.addPaymentRequest(address, amount, symbol, chainId) + } + + function removePaymentRequest(index) { + requestPaymentModel.removeItemWithIndex(index) + } }