refactor(Wallet/SendModal): Selected Recipients component review, backend dependencies cleanup
- Component name changed to be more precise with what it represents. - Removed `RootStore` dependency from `Helpers.qml`. - Removed unnecessary method `lookupAddressObject` from `RootStore`. - Updated `SendModal` property bindings related to recipient. - Some activity controller interaction details moved to transactions store instead of being directly in `SendModal`. - Type enum living in `RecipientSelectorPanel` is moved to `Helpers`. Since it doesn't depends on the specific component and it's used in other global places. Part of #15208
This commit is contained in:
parent
4dc170688e
commit
18e230bf91
|
@ -331,6 +331,7 @@ Item {
|
|||
}
|
||||
onLaunchBridgeModal: {
|
||||
root.sendModalPopup.preSelectedSendType = Constants.SendType.Bridge
|
||||
root.sendModalPopup.preSelectedRecipient = root.sendModalPopup.preSelectedAccount.address
|
||||
root.sendModalPopup.preSelectedHoldingID = walletStore.currentViewedHoldingID
|
||||
root.sendModalPopup.preSelectedHoldingType = walletStore.currentViewedHoldingType
|
||||
root.sendModalPopup.onlyAssets = true
|
||||
|
|
|
@ -308,27 +308,6 @@ QtObject {
|
|||
return name
|
||||
}
|
||||
|
||||
enum LookupType {
|
||||
Account = 0,
|
||||
SavedAddress = 1
|
||||
}
|
||||
|
||||
// Returns object of type {type: null, object: null} or null if lookup didn't find anything
|
||||
function lookupAddressObject(address) {
|
||||
let res = null
|
||||
let acc = SQUtils.ModelUtils.getByKey(root.accounts, "address", address)
|
||||
if (acc) {
|
||||
res = {type: RootStore.LookupType.Account, object: acc}
|
||||
} else {
|
||||
let sa = SQUtils.ModelUtils.getByKey(walletSectionSavedAddresses.model, "address", address)
|
||||
if (sa) {
|
||||
res = {type: RootStore.LookupType.SavedAddress, object: sa}
|
||||
}
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function getAssetForSendTx(tx) {
|
||||
if (tx.isNFT) {
|
||||
return {
|
||||
|
@ -348,8 +327,8 @@ QtObject {
|
|||
if (!tx || tx.txType !== Constants.TransactionType.Send)
|
||||
return false
|
||||
|
||||
let res = root.lookupAddressObject(tx.sender)
|
||||
if (!res || res.type !== RootStore.LookupType.Account || res.object.walletType == Constants.watchWalletType)
|
||||
let res = SQUtils.ModelUtils.getByKey(root.accounts, "address", tx.sender)
|
||||
if (!res || res.object.walletType === Constants.watchWalletType)
|
||||
return false
|
||||
|
||||
if (tx.isNFT) {
|
||||
|
|
|
@ -774,7 +774,13 @@ Item {
|
|||
}
|
||||
onClicked: {
|
||||
let asset = WalletStores.RootStore.getAssetForSendTx(tx)
|
||||
let req = Helpers.lookupAddressesForSendModal(tx.sender, tx.recipient, asset, tx.isNFT, tx.amount)
|
||||
const req = Helpers.lookupAddressesForSendModal(WalletStores.RootStore.accounts,
|
||||
WalletStores.RootStore.savedAddresses,
|
||||
tx.sender,
|
||||
tx.recipient,
|
||||
asset,
|
||||
tx.isNFT,
|
||||
tx.amount)
|
||||
|
||||
root.sendModal.preSelectedAccount = req.preSelectedAccount
|
||||
root.sendModal.preSelectedRecipient = req.preSelectedRecipient
|
||||
|
|
|
@ -25,7 +25,7 @@ import shared.popups 1.0
|
|||
import shared.popups.keycard 1.0
|
||||
import shared.status 1.0
|
||||
import shared.stores 1.0
|
||||
import shared.popups.send 1.0
|
||||
import shared.popups.send 1.0 as SendPopups
|
||||
import shared.popups.send.views 1.0
|
||||
import shared.stores.send 1.0
|
||||
|
||||
|
@ -1500,7 +1500,7 @@ Item {
|
|||
function open(address = "") {
|
||||
if (!!address) {
|
||||
preSelectedRecipient = address
|
||||
preSelectedRecipientType = TabAddressSelectorView.Type.Address
|
||||
preSelectedRecipientType = SendPopups.Helpers.RecipientAddressObjectType.Address
|
||||
}
|
||||
this.active = true
|
||||
this.item.open()
|
||||
|
@ -1520,7 +1520,7 @@ Item {
|
|||
property string preDefinedAmountToSend
|
||||
property bool onlyAssets: false
|
||||
|
||||
sourceComponent: SendModal {
|
||||
sourceComponent: SendPopups.SendModal {
|
||||
onlyAssets: sendModal.onlyAssets
|
||||
store: appMain.transactionStore
|
||||
loginType: appMain.rootStore.loginType
|
||||
|
|
|
@ -6,21 +6,28 @@ import QtQml 2.15
|
|||
import utils 1.0
|
||||
import shared.stores 1.0
|
||||
import shared.stores.send 1.0
|
||||
import AppLayouts.Wallet.stores 1.0 as WalletStores
|
||||
|
||||
import StatusQ.Core 0.1
|
||||
import StatusQ.Core.Utils 0.1 as SQUtils
|
||||
|
||||
import "./panels"
|
||||
import shared.popups.send.panels 1.0
|
||||
import "./controls"
|
||||
import "./views"
|
||||
|
||||
QtObject {
|
||||
id: root
|
||||
|
||||
enum RecipientAddressObjectType {
|
||||
Address, // Just a string with the address information / default
|
||||
Account, // Wallet account object
|
||||
SavedAddress, // Saved addresses object
|
||||
RecentsAddress // Recent addresses object got from transactions history
|
||||
}
|
||||
|
||||
function createSendModalRequirements() {
|
||||
return {
|
||||
preSelectedAccount: null,
|
||||
preSelectedRecipientType: TabAddressSelectorView.Type.Address,
|
||||
preSelectedRecipientType: Helpers.RecipientAddressObjectType.Address,
|
||||
preSelectedRecipient: null,
|
||||
preSelectedHoldingType: Constants.TokenType.Unknown,
|
||||
preSelectedHolding: null,
|
||||
|
@ -31,30 +38,40 @@ QtObject {
|
|||
}
|
||||
|
||||
// \c token is an collectible object in case of \c isCollectible == true otherwise a token code (e.g. "ETH")
|
||||
function lookupAddressesForSendModal(senderAddress, recipientAddress, token, isCollectible, amount) {
|
||||
function lookupAddressesForSendModal(accountsModel,
|
||||
savedAddressesModel,
|
||||
senderAddress,
|
||||
recipientAddress,
|
||||
token,
|
||||
isCollectible,
|
||||
amount) {
|
||||
let req = createSendModalRequirements()
|
||||
|
||||
req.preSelectedSendType = Constants.SendType.Transfer
|
||||
|
||||
// Sender properties:
|
||||
let senderAccount = null
|
||||
let resolvedAcc = WalletStores.RootStore.lookupAddressObject(senderAddress)
|
||||
if (resolvedAcc && resolvedAcc.type == WalletStores.RootStore.LookupType.Account) {
|
||||
req.preSelectedAccount = resolvedAcc.object
|
||||
let resolvedAcc = SQUtils.ModelUtils.getByKey(accountsModel, "address", senderAddress)
|
||||
if (resolvedAcc) {
|
||||
req.preSelectedAccount = resolvedAcc
|
||||
req.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Account
|
||||
}
|
||||
|
||||
let res = WalletStores.RootStore.lookupAddressObject(recipientAddress)
|
||||
if (res) {
|
||||
if (res.type == WalletStores.RootStore.LookupType.Account) {
|
||||
req.preSelectedRecipientType = TabAddressSelectorView.Type.Account
|
||||
req.preSelectedRecipient = res.object
|
||||
} else if (res.type == WalletStores.RootStore.LookupType.SavedAddress) {
|
||||
req.preSelectedRecipientType = TabAddressSelectorView.Type.SavedAddress
|
||||
req.preSelectedRecipient = res.object
|
||||
}
|
||||
// Recipients properties:
|
||||
const resAcc = SQUtils.ModelUtils.getByKey(accountsModel, "address", recipientAddress)
|
||||
let resSaved = SQUtils.ModelUtils.getByKey(savedAddressesModel, "address", recipientAddress)
|
||||
if (resAcc) {
|
||||
req.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Account
|
||||
req.preSelectedRecipient = resAcc
|
||||
} else if (resSaved) {
|
||||
req.preSelectedRecipientType = Helpers.RecipientAddressObjectType.SavedAddress
|
||||
req.preSelectedRecipient = resSaved
|
||||
} else {
|
||||
req.preSelectedRecipientType = TabAddressSelectorView.Type.Address
|
||||
req.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
|
||||
req.preSelectedRecipient = recipientAddress
|
||||
}
|
||||
|
||||
// Holdings related properties:
|
||||
if (isCollectible) {
|
||||
req.preSelectedHoldingType = Constants.TokenType.ERC721
|
||||
req.preSelectedHolding = token
|
||||
|
|
|
@ -22,7 +22,7 @@ import StatusQ.Popups.Dialog 0.1
|
|||
|
||||
import AppLayouts.Wallet.controls 1.0
|
||||
|
||||
import "./panels"
|
||||
import shared.popups.send.panels 1.0
|
||||
import "./controls"
|
||||
import "./views"
|
||||
import "./models"
|
||||
|
@ -31,10 +31,11 @@ StatusDialog {
|
|||
id: popup
|
||||
|
||||
property var preSelectedAccount: selectedAccount
|
||||
// expected content depends on the preSelectedRecipientType value.
|
||||
// If type Address this must be a string else it expects an object. See RecipientView.selectedRecipientType
|
||||
property var preSelectedRecipient
|
||||
property int preSelectedRecipientType: TabAddressSelectorView.Type.Address
|
||||
|
||||
// Recipient properties definition
|
||||
property alias preSelectedRecipient: recipientInputLoader.selectedRecipient
|
||||
property alias preSelectedRecipientType: recipientInputLoader.selectedRecipientType
|
||||
|
||||
property string preDefinedAmountToSend
|
||||
// token symbol
|
||||
property string preSelectedHoldingID
|
||||
|
@ -70,7 +71,7 @@ StatusDialog {
|
|||
|
||||
property var recalculateRoutesAndFees: Backpressure.debounce(popup, 600, function() {
|
||||
if(!!popup.preSelectedAccount && !!holdingSelector.selectedItem
|
||||
&& recipientLoader.ready && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)) {
|
||||
&& recipientInputLoader.ready && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)) {
|
||||
popup.isLoading = true
|
||||
popup.store.suggestedRoutes(d.isCollectiblesTransfer ? "1" : amountToSendInput.cryptoValueToSend)
|
||||
}
|
||||
|
@ -87,13 +88,13 @@ StatusDialog {
|
|||
readonly property var currencyStore: store.currencyStore
|
||||
readonly property int errorType: !amountToSendInput.input.valid && (!isCollectiblesTransfer) ? Constants.SendAmountExceedsBalance :
|
||||
(popup.bestRoutes && popup.bestRoutes.count === 0 &&
|
||||
!!amountToSendInput.input.text && recipientLoader.ready && !popup.isLoading) ?
|
||||
!!amountToSendInput.input.text && recipientInputLoader.ready && !popup.isLoading) ?
|
||||
Constants.NoRoute : Constants.NoError
|
||||
readonly property double maxFiatBalance: isSelectedHoldingValidAsset ? selectedHolding.currentCurrencyBalance : 0
|
||||
readonly property double maxCryptoBalance: isSelectedHoldingValidAsset ? selectedHolding.currentBalance : 0
|
||||
readonly property double maxInputBalance: amountToSendInput.inputIsFiat ? maxFiatBalance : maxCryptoBalance
|
||||
readonly property string inputSymbol: amountToSendInput.inputIsFiat ? currencyStore.currentCurrency : !!d.selectedHolding && !!d.selectedHolding.symbol ? d.selectedHolding.symbol: ""
|
||||
readonly property bool errorMode: popup.isLoading || !recipientLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !(amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)
|
||||
readonly property bool errorMode: popup.isLoading || !recipientInputLoader.ready ? false : errorType !== Constants.NoError || networkSelector.errorMode || !(amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)
|
||||
readonly property string uuid: Utils.uuid()
|
||||
property bool isPendingTx: false
|
||||
property string totalTimeEstimate
|
||||
|
@ -222,20 +223,6 @@ StatusDialog {
|
|||
if(!!popup.preDefinedAmountToSend) {
|
||||
amountToSendInput.input.text = Number(popup.preDefinedAmountToSend).toLocaleString(Qt.locale(), 'f', -128)
|
||||
}
|
||||
|
||||
if(!!popup.preSelectedRecipient) {
|
||||
recipientLoader.selectedRecipientType = popup.preSelectedRecipientType
|
||||
if (popup.preSelectedRecipientType === TabAddressSelectorView.Type.Address) {
|
||||
recipientLoader.selectedRecipient = {address: popup.preSelectedRecipient}
|
||||
} else {
|
||||
recipientLoader.selectedRecipient = popup.preSelectedRecipient
|
||||
}
|
||||
}
|
||||
|
||||
if(d.isBridgeTx) {
|
||||
recipientLoader.selectedRecipientType = TabAddressSelectorView.Type.Address
|
||||
recipientLoader.selectedRecipient = {address: popup.preSelectedAccount.address}
|
||||
}
|
||||
}
|
||||
|
||||
onClosed: popup.store.resetStoredProperties()
|
||||
|
@ -381,7 +368,7 @@ StatusDialog {
|
|||
|
||||
formatCurrencyAmount: d.currencyStore.formatCurrencyAmount
|
||||
onReCalculateSuggestedRoute: popup.recalculateRoutesAndFees()
|
||||
input.input.tabNavItem: recipientLoader.item
|
||||
input.input.tabNavItem: recipientInputLoader.item
|
||||
Keys.onTabPressed: event.accepted = true
|
||||
}
|
||||
|
||||
|
@ -419,7 +406,8 @@ StatusDialog {
|
|||
color: Theme.palette.directColor1
|
||||
}
|
||||
RecipientView {
|
||||
id: recipientLoader
|
||||
id: recipientInputLoader
|
||||
|
||||
Layout.fillWidth: true
|
||||
store: popup.store
|
||||
isCollectiblesTransfer: d.isCollectiblesTransfer
|
||||
|
@ -467,21 +455,53 @@ StatusDialog {
|
|||
}
|
||||
}
|
||||
|
||||
TabAddressSelectorView {
|
||||
id: addressSelector
|
||||
RecipientSelectorPanel {
|
||||
id: recipientsPanel
|
||||
|
||||
Layout.fillHeight: true
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: Style.current.padding
|
||||
Layout.leftMargin: Style.current.xlPadding
|
||||
Layout.rightMargin: Style.current.xlPadding
|
||||
Layout.bottomMargin: Style.current.padding
|
||||
visible: !recipientLoader.ready && !d.isBridgeTx && !!d.selectedHolding
|
||||
|
||||
store: popup.store
|
||||
selectedAccount: popup.preSelectedAccount
|
||||
// TODO: To be removed after all other refactors done (initial tokens selector page removed, bridge modal separated)
|
||||
// This panel must be shown by default if no recipient already selected, otherwise, hidden
|
||||
visible: !recipientInputLoader.ready && !d.isBridgeTx && !!d.selectedHolding
|
||||
|
||||
savedAddressesModel: popup.store.savedAddressesModel
|
||||
myAccountsModel: SortFilterProxyModel {
|
||||
sourceModel: popup.store.accounts
|
||||
|
||||
proxyRoles: FastExpressionRole {
|
||||
function getColorizedChainShortNames(preferredSharingChainIds, address){
|
||||
const chainShortNames = popup.store.getNetworkShortNames(preferredSharingChainIds)
|
||||
return WalletUtils.colorizedChainPrefix(chainShortNames) + address
|
||||
}
|
||||
|
||||
name: "colorizedChainShortNames"
|
||||
expectedRoles: ["preferredSharingChainIds", "address"]
|
||||
expression: getColorizedChainShortNames(model.preferredSharingChainIds, model.address)
|
||||
}
|
||||
}
|
||||
recentRecipientsModel: popup.store.tempActivityController1Model // Use Layer1 controller since this could go on top of other activity lists
|
||||
|
||||
onRecipientSelected: {
|
||||
recipientLoader.selectedRecipientType = type
|
||||
recipientLoader.selectedRecipient = recipient
|
||||
popup.preSelectedRecipientType = type
|
||||
popup.preSelectedRecipient = recipient
|
||||
}
|
||||
|
||||
// Only request transactions history update if visually needed:
|
||||
onRecentRecipientsTabSelected: popup.store.updateRecentRecipientsActivity(popup.preSelectedAccount)
|
||||
|
||||
Connections {
|
||||
target: popup
|
||||
function onPreSelectedAccountChanged() {
|
||||
// Only request transactions history update if visually needed:
|
||||
if(recipientsPanel.recentRecipientsTabVisible) {
|
||||
popup.store.updateRecentRecipientsActivity(popup.preSelectedAccount)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -499,7 +519,7 @@ StatusDialog {
|
|||
|
||||
contentWidth: availableWidth
|
||||
|
||||
visible: recipientLoader.ready && !!d.selectedHolding && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)
|
||||
visible: recipientInputLoader.ready && !!d.selectedHolding && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer)
|
||||
|
||||
objectName: "sendModalScroll"
|
||||
|
||||
|
@ -514,8 +534,8 @@ StatusDialog {
|
|||
|
||||
store: popup.store
|
||||
interactive: popup.interactive
|
||||
selectedRecipient: recipientLoader.selectedRecipient
|
||||
ensAddressOrEmpty: recipientLoader.resolvedENSAddress
|
||||
selectedRecipient: popup.preSelectedRecipient
|
||||
ensAddressOrEmpty: recipientInputLoader.resolvedENSAddress
|
||||
amountToSend: amountToSendInput.cryptoValueToSendFloat
|
||||
minSendCryptoDecimals: amountToSendInput.minSendCryptoDecimals
|
||||
minReceiveCryptoDecimals: amountToSendInput.minReceiveCryptoDecimals
|
||||
|
@ -541,7 +561,7 @@ StatusDialog {
|
|||
maxFiatFees: popup.isLoading ? "..." : d.currencyStore.formatCurrencyAmount(d.totalFeesInFiat, d.currencyStore.currentCurrency)
|
||||
totalTimeEstimate: popup.isLoading? "..." : d.totalTimeEstimate
|
||||
pending: d.isPendingTx || popup.isLoading
|
||||
visible: recipientLoader.ready && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer) && !d.errorMode
|
||||
visible: recipientInputLoader.ready && (amountToSendInput.inputNumberValid || d.isCollectiblesTransfer) && !d.errorMode
|
||||
onNextButtonClicked: popup.sendTransaction()
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import QtQuick.Dialogs 1.3
|
|||
import utils 1.0
|
||||
import shared.controls 1.0 as SharedControls
|
||||
import shared.stores 1.0
|
||||
import shared.popups.send 1.0
|
||||
|
||||
import AppLayouts.Wallet 1.0
|
||||
|
||||
|
@ -23,10 +24,16 @@ import "../views"
|
|||
Item {
|
||||
id: root
|
||||
|
||||
property var selectedAccount
|
||||
property var store
|
||||
property var savedAddressesModel
|
||||
property var myAccountsModel
|
||||
property var recentRecipientsModel
|
||||
|
||||
readonly property bool recentRecipientsTabVisible: recipientTypeTabBar.currentIndex === 2 // Recent tab
|
||||
|
||||
// This should only pass a `key` role to identify the object but not necessary to pass the complete object structure
|
||||
// TODO issue: #15492
|
||||
signal recipientSelected(var recipient, int type)
|
||||
signal recentRecipientsTabSelected
|
||||
|
||||
enum Type {
|
||||
Address,
|
||||
|
@ -36,21 +43,16 @@ Item {
|
|||
None
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
// Use Layer1 controller since this could go on top of other activity lists
|
||||
readonly property var activityController: root.store.tmpActivityController1
|
||||
}
|
||||
|
||||
StatusTabBar {
|
||||
id: accountSelectionTabBar
|
||||
id: recipientTypeTabBar
|
||||
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
width: parent.width
|
||||
|
||||
StatusTabButton {
|
||||
width: implicitWidth
|
||||
objectName: "savedAddressesTab"
|
||||
text: qsTr("Saved")
|
||||
}
|
||||
StatusTabButton {
|
||||
|
@ -60,35 +62,38 @@ Item {
|
|||
}
|
||||
StatusTabButton {
|
||||
width: implicitWidth
|
||||
objectName: "recentAddressesTab"
|
||||
text: qsTr("Recent")
|
||||
}
|
||||
}
|
||||
|
||||
// To-do adapt to new design and make block white/black once the list items etc support new color scheme
|
||||
Rectangle {
|
||||
anchors.top: accountSelectionTabBar.bottom
|
||||
anchors.top: recipientTypeTabBar.bottom
|
||||
anchors.topMargin: -5
|
||||
height: parent.height - accountSelectionTabBar.height
|
||||
height: parent.height - recipientTypeTabBar.height
|
||||
width: parent.width
|
||||
color: Theme.palette.indirectColor1
|
||||
radius: 8
|
||||
|
||||
StackLayout {
|
||||
currentIndex: accountSelectionTabBar.currentIndex
|
||||
|
||||
currentIndex: recipientTypeTabBar.currentIndex
|
||||
anchors.fill: parent
|
||||
|
||||
StatusListView {
|
||||
id: savedAddresses
|
||||
objectName: "savedAddressesList"
|
||||
|
||||
model: root.store.savedAddressesModel
|
||||
model: root.savedAddressesModel
|
||||
header: savedAddresses.count > 0 ? search : nothingInList
|
||||
headerPositioning: ListView.OverlayHeader
|
||||
delegate: SavedAddressListItem {
|
||||
implicitWidth: ListView.view.width
|
||||
modelData: model
|
||||
visible: !savedAddresses.headerItem.text || name.toLowerCase().includes(savedAddresses.headerItem.text)
|
||||
onClicked: recipientSelected(modelData, TabAddressSelectorView.Type.SavedAddress)
|
||||
// This should only pass a `key` role to identify the saved addresses object but not necessary to pass the complete object structure
|
||||
// TODO issue: #15492
|
||||
onClicked: recipientSelected(modelData, Helpers.RecipientAddressObjectType.SavedAddress)
|
||||
}
|
||||
Component {
|
||||
id: search
|
||||
|
@ -129,12 +134,12 @@ Item {
|
|||
walletType: model.walletType
|
||||
migratedToKeycard: model.migratedToKeycard ?? false
|
||||
accountBalance: model.accountBalance ?? null
|
||||
chainShortNames: {
|
||||
const chainShortNames = store.getNetworkShortNames(model.preferredSharingChainIds)
|
||||
return WalletUtils.colorizedChainPrefix(chainShortNames)
|
||||
}
|
||||
chainShortNames: model.colorizedChainShortNames ?? ""
|
||||
// This should only pass a `key` role to identify the accounts object but not necessary to pass the complete object structure
|
||||
// TODO issue: #15492
|
||||
onClicked: recipientSelected({name: model.name,
|
||||
address: model.address,
|
||||
color: model.color,
|
||||
colorId: model.colorId,
|
||||
emoji: model.emoji,
|
||||
walletType: model.walletType,
|
||||
|
@ -142,14 +147,16 @@ Item {
|
|||
preferredSharingChainIds: model.preferredSharingChainIds,
|
||||
migratedToKeycard: model.migratedToKeycard
|
||||
},
|
||||
TabAddressSelectorView.Type.Account)
|
||||
Helpers.RecipientAddressObjectType.Account)
|
||||
|
||||
}
|
||||
|
||||
model: root.store.accounts
|
||||
model: root.myAccountsModel
|
||||
}
|
||||
|
||||
StatusListView {
|
||||
id: recents
|
||||
objectName: "recentReceiversList"
|
||||
|
||||
header: StatusBaseText {
|
||||
height: visible ? 56 : 0
|
||||
|
@ -192,31 +199,17 @@ Item {
|
|||
text: LocaleUtils.currencyAmountToLocaleString(entry.amountCurrency)
|
||||
}
|
||||
]
|
||||
onClicked: recipientSelected(entry, TabAddressSelectorView.Type.RecentsAddress)
|
||||
// This should only pass a `key` role to identify the recent activity object but not necessary to pass the complete object structure
|
||||
// TODO issue: #15492
|
||||
onClicked: recipientSelected(entry, Helpers.RecipientAddressObjectType.RecentsAddress)
|
||||
}
|
||||
|
||||
model: d.activityController.model
|
||||
model: root.recentRecipientsModel
|
||||
|
||||
onVisibleChanged: {
|
||||
if (visible) {
|
||||
updateRecentsActivity()
|
||||
}
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: root
|
||||
function onSelectedAccountChanged() {
|
||||
if (visible) {
|
||||
recents.updateRecentsActivity()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateRecentsActivity() {
|
||||
if(root.selectedAccount) {
|
||||
d.activityController.setFilterAddressesJson(JSON.stringify([root.selectedAccount.address]), false)
|
||||
}
|
||||
d.activityController.updateFilter()
|
||||
root.recentRecipientsTabSelected()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,2 +1,3 @@
|
|||
HoldingItemSelector 1.0 HoldingItemSelector.qml
|
||||
HoldingSelector 1.0 HoldingSelector.qml
|
||||
RecipientSelectorPanel 1.0 RecipientSelectorPanel.qml
|
||||
|
|
|
@ -10,6 +10,8 @@ import AppLayouts.Wallet 1.0
|
|||
|
||||
import shared.controls 1.0 as SharedControls
|
||||
import shared.stores.send 1.0
|
||||
import shared.popups.send.panels 1.0
|
||||
import shared.popups.send 1.0
|
||||
|
||||
import utils 1.0
|
||||
|
||||
|
@ -24,7 +26,7 @@ Loader {
|
|||
property bool interactive: true
|
||||
property var selectedAsset
|
||||
property var selectedRecipient: null
|
||||
property int selectedRecipientType
|
||||
property int selectedRecipientType: Helpers.RecipientAddressObjectType.Address
|
||||
|
||||
readonly property bool ready: (d.isAddressValid || !!resolvedENSAddress) && !d.isPending
|
||||
property string addressText
|
||||
|
@ -37,15 +39,15 @@ Loader {
|
|||
|
||||
onSelectedRecipientChanged: {
|
||||
root.isLoading()
|
||||
if(!!root.selectedRecipient && root.selectedRecipientType !== TabAddressSelectorView.Type.None) {
|
||||
if(!!root.selectedRecipient) {
|
||||
let preferredChainIds = []
|
||||
switch(root.selectedRecipientType) {
|
||||
case TabAddressSelectorView.Type.Account: {
|
||||
case Helpers.RecipientAddressObjectType.Account: {
|
||||
root.addressText = root.selectedRecipient.address
|
||||
preferredChainIds = root.selectedRecipient.preferredSharingChainIds
|
||||
break
|
||||
}
|
||||
case TabAddressSelectorView.Type.SavedAddress: {
|
||||
case Helpers.RecipientAddressObjectType.SavedAddress: {
|
||||
root.addressText = root.selectedRecipient.address
|
||||
|
||||
// Resolve before using
|
||||
|
@ -56,15 +58,15 @@ Loader {
|
|||
preferredChainIds = store.getShortChainIds(root.selectedRecipient.chainShortNames)
|
||||
break
|
||||
}
|
||||
case TabAddressSelectorView.Type.RecentsAddress: {
|
||||
case Helpers.RecipientAddressObjectType.RecentsAddress: {
|
||||
let isIncoming = root.selectedRecipient.txType === Constants.TransactionType.Receive
|
||||
root.addressText = isIncoming ? root.selectedRecipient.sender : root.selectedRecipient.recipient
|
||||
root.item.input.text = root.addressText
|
||||
break
|
||||
}
|
||||
case TabAddressSelectorView.Type.Address: {
|
||||
root.addressText = root.selectedRecipient.address
|
||||
root.item.input.text = root.selectedRecipient.address
|
||||
case Helpers.RecipientAddressObjectType.Address: {
|
||||
root.addressText = root.selectedRecipient
|
||||
root.item.input.text = root.addressText
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -91,7 +93,7 @@ Loader {
|
|||
function clearValues() {
|
||||
root.addressText = ""
|
||||
root.resolvedENSAddress = ""
|
||||
root.selectedRecipientType = TabAddressSelectorView.Type.None
|
||||
root.selectedRecipientType = Helpers.RecipientAddressObjectType.Address
|
||||
root.selectedRecipient = null
|
||||
}
|
||||
property Timer waitTimer: Timer {
|
||||
|
@ -113,9 +115,9 @@ Loader {
|
|||
}
|
||||
}
|
||||
|
||||
sourceComponent: root.selectedRecipientType === TabAddressSelectorView.Type.SavedAddress
|
||||
sourceComponent: root.selectedRecipientType === Helpers.RecipientAddressObjectType.SavedAddress
|
||||
? savedAddressRecipient
|
||||
: root.selectedRecipientType === TabAddressSelectorView.Type.Account
|
||||
: root.selectedRecipientType === Helpers.RecipientAddressObjectType.Account
|
||||
? myAccountRecipient : addressRecipient
|
||||
|
||||
Component {
|
||||
|
|
|
@ -7,5 +7,4 @@ NetworkSelector 1.0 NetworkSelector.qml
|
|||
NetworksSimpleRoutingView 1.0 NetworksSimpleRoutingView.qml
|
||||
RecipientView 1.0 RecipientView.qml
|
||||
TransactionModalFooter 1.0 TransactionModalFooter.qml
|
||||
TabAddressSelectorView 1.0 TabAddressSelectorView.qml
|
||||
TokenListView 1.0 TokenListView.qml
|
||||
|
|
|
@ -32,7 +32,8 @@ QtObject {
|
|||
property var nestedCollectiblesModel: walletSectionSendInst.nestedCollectiblesModel
|
||||
property bool areTestNetworksEnabled: networksModule.areTestNetworksEnabled
|
||||
property var tmpActivityController0: walletSection.tmpActivityController0
|
||||
property var tmpActivityController1: walletSection.tmpActivityController1
|
||||
readonly property var _tmpActivityController1: walletSection.tmpActivityController1
|
||||
readonly property var tempActivityController1Model: _tmpActivityController1.model
|
||||
property var savedAddressesModel: SortFilterProxyModel {
|
||||
sourceModel: walletSectionSavedAddresses.model
|
||||
filters: [
|
||||
|
@ -226,4 +227,12 @@ QtObject {
|
|||
function formatCurrencyAmountFromBigInt(balance, symbol, decimals, options = null) {
|
||||
return currencyStore.formatCurrencyAmountFromBigInt(balance, symbol, decimals, options)
|
||||
}
|
||||
|
||||
function updateRecentRecipientsActivity(walletAccount) {
|
||||
if(walletAccount && walletAccount.address) {
|
||||
_tmpActivityController1.setFilterAddressesJson(JSON.stringify([walletAccount.address]),
|
||||
false)
|
||||
}
|
||||
_tmpActivityController1.updateFilter()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -318,7 +318,13 @@ ColumnLayout {
|
|||
return
|
||||
let asset = WalletStores.RootStore.getAssetForSendTx(tx)
|
||||
|
||||
let req = Helpers.lookupAddressesForSendModal(tx.sender, tx.recipient, asset, tx.isNFT, tx.amount)
|
||||
const req = Helpers.lookupAddressesForSendModal(WalletStores.RootStore.accounts,
|
||||
WalletStores.RootStore.savedAddresses,
|
||||
tx.sender,
|
||||
tx.recipient,
|
||||
asset,
|
||||
tx.isNFT,
|
||||
tx.amount)
|
||||
|
||||
root.sendModal.preSelectedAccount = req.preSelectedAccount
|
||||
root.sendModal.preSelectedRecipient = req.preSelectedRecipient
|
||||
|
|
Loading…
Reference in New Issue