fix: optimizes send modal flow for buying stickers
This commit is contained in:
parent
46f34ec8fc
commit
11f1e1541b
|
@ -151,11 +151,11 @@ StackLayout {
|
|||
contactsStore: root.contactsStore
|
||||
sharedRootStore: root.sharedRootStore
|
||||
rootStore: root.rootStore
|
||||
transactionStore: root.transactionStore
|
||||
createChatPropertiesStore: root.createChatPropertiesStore
|
||||
communitiesStore: root.communitiesStore
|
||||
walletAssetsStore: root.walletAssetsStore
|
||||
currencyStore: root.currencyStore
|
||||
sendModalPopup: root.sendModalPopup
|
||||
sectionItemModel: root.sectionItemModel
|
||||
amIMember: sectionItem.amIMember
|
||||
amISectionAdmin: root.sectionItemModel.memberRole === Constants.memberRole.owner ||
|
||||
|
|
|
@ -283,6 +283,8 @@ QtObject {
|
|||
|
||||
property var mainModuleInst: mainModule
|
||||
|
||||
readonly property string appNetworkId: mainModuleInst.appNetworkId
|
||||
|
||||
property var communitiesModuleInst: communitiesModule
|
||||
property var communitiesList: communitiesModuleInst.model
|
||||
|
||||
|
|
|
@ -44,11 +44,11 @@ StatusSectionLayout {
|
|||
|
||||
property SharedStores.RootStore sharedRootStore
|
||||
property ChatStores.RootStore rootStore
|
||||
required property SendStores.TransactionStore transactionStore
|
||||
property ChatStores.CreateChatPropertiesStore createChatPropertiesStore
|
||||
property CommunitiesStores.CommunitiesStore communitiesStore
|
||||
required property WalletStore.WalletAssetsStore walletAssetsStore
|
||||
required property SharedStores.CurrenciesStore currencyStore
|
||||
required property var sendModalPopup
|
||||
property var sectionItemModel
|
||||
|
||||
property var emojiPopup
|
||||
|
@ -307,8 +307,8 @@ StatusSectionLayout {
|
|||
Component {
|
||||
id: statusStickerPackClickPopup
|
||||
StatusStickerPackClickPopup{
|
||||
transactionStore: root.transactionStore
|
||||
walletAssetsStore: root.walletAssetsStore
|
||||
sendModalPopup: root.sendModalPopup
|
||||
onClosed: {
|
||||
destroy();
|
||||
}
|
||||
|
|
|
@ -651,8 +651,8 @@ Item {
|
|||
active: appMain.rootStore.mainModuleInst.sectionsLoaded
|
||||
sourceComponent: StatusStickersPopup {
|
||||
store: appMain.rootChatStore
|
||||
transactionStore: appMain.transactionStore
|
||||
walletAssetsStore: appMain.walletAssetsStore
|
||||
sendModalPopup: sendModal
|
||||
|
||||
isWalletEnabled: appMain.rootStore.profileSectionStore.profileStore.isWalletEnabled
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ Item {
|
|||
|
||||
property ChatStores.RootStore store
|
||||
property var stickerPacks: ChatStores.StickerPackData {}
|
||||
required property TransactionStore transactionStore
|
||||
required property WalletAssetsStore walletAssetsStore
|
||||
required property var sendModalPopup
|
||||
property string packId
|
||||
property bool marketVisible
|
||||
property bool isWalletEnabled
|
||||
|
@ -38,6 +38,26 @@ Item {
|
|||
signal updateClicked(string packId)
|
||||
signal buyClicked(string packId)
|
||||
|
||||
QtObject {
|
||||
id: d
|
||||
|
||||
function runSendModal(price, packId) {
|
||||
|
||||
const token = ModelUtils.getByKey(root.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", root.store.stickersStore.getStatusTokenKey())
|
||||
|
||||
root.sendModalPopup.interactive = false
|
||||
root.sendModalPopup.preSelectedRecipient = root.store.stickersStore.getStickersMarketAddress()
|
||||
root.sendModalPopup.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
|
||||
root.sendModalPopup.preSelectedHoldingID = !!token && !!token.symbol ? token.symbol : ""
|
||||
root.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC20
|
||||
root.sendModalPopup.preSelectedSendType = Constants.SendType.StickersBuy
|
||||
root.sendModalPopup.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(parseFloat(price))
|
||||
root.sendModalPopup.preSelectedChainId = root.store.appNetworkId
|
||||
root.sendModalPopup.stickersPackId = packId
|
||||
root.sendModalPopup.open()
|
||||
}
|
||||
}
|
||||
|
||||
StatusGridView {
|
||||
id: availableStickerPacks
|
||||
objectName: "stickerMarketStatusGridView"
|
||||
|
@ -154,7 +174,7 @@ Item {
|
|||
onCancelClicked: root.cancelClicked(packId)
|
||||
onUpdateClicked: root.updateClicked(packId)
|
||||
onBuyClicked: {
|
||||
Global.openPopup(stickerPackPurchaseModal, {price, packId})
|
||||
d.runSendModal(price, packId)
|
||||
root.buyClicked(packId)
|
||||
}
|
||||
}
|
||||
|
@ -187,7 +207,7 @@ Item {
|
|||
onCancelClicked: root.cancelClicked(packId)
|
||||
onUpdateClicked: root.updateClicked(packId)
|
||||
onBuyClicked: {
|
||||
Global.openPopup(stickerPackPurchaseModal, {price, packId})
|
||||
d.runSendModal(price, packId)
|
||||
root.buyClicked(packId)
|
||||
}
|
||||
}
|
||||
|
@ -196,49 +216,6 @@ Item {
|
|||
}
|
||||
}
|
||||
|
||||
Component {
|
||||
id: stickerPackPurchaseModal
|
||||
SendModal {
|
||||
id: buyStickersModal
|
||||
|
||||
required property int price
|
||||
required property string packId
|
||||
|
||||
interactive: false
|
||||
store: root.transactionStore
|
||||
preSelectedSendType: Constants.SendType.StickersBuy
|
||||
preSelectedRecipient: root.store.stickersStore.getStickersMarketAddress()
|
||||
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
|
||||
stickersPackId: packId
|
||||
preSelectedHoldingID: {
|
||||
let token = ModelUtils.getByKey(root.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", root.store.stickersStore.getStatusTokenKey())
|
||||
return !!token && !!token.symbol ? token.symbol : ""
|
||||
}
|
||||
preSelectedHoldingType: Constants.TokenType.ERC20
|
||||
|
||||
Connections {
|
||||
target: root.store.stickersStore.stickersModule
|
||||
function onTransactionWasSent(chainId: int, txHash: string, error: string) {
|
||||
if (!!error) {
|
||||
if (error.includes(Constants.walletSection.cancelledMessage)) {
|
||||
return
|
||||
}
|
||||
buyStickersModal.sendingError.text = error
|
||||
return buyStickersModal.sendingError.open()
|
||||
}
|
||||
let url = "%1/%2".arg(buyStickersModal.store.getEtherscanLink(chainId)).arg(txHash)
|
||||
Global.displayToastMessage(qsTr("Transaction pending..."),
|
||||
qsTr("View on etherscan"),
|
||||
"",
|
||||
true,
|
||||
Constants.ephemeralNotificationType.normal,
|
||||
url)
|
||||
buyStickersModal.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: footer
|
||||
height: 44
|
||||
|
|
|
@ -25,8 +25,8 @@ ModalPopup {
|
|||
property string packId
|
||||
|
||||
property ChatStores.RootStore store
|
||||
required property TransactionStore transactionStore
|
||||
required property WalletAssetsStore walletAssetsStore
|
||||
required property var sendModalPopup
|
||||
property string thumbnail: ""
|
||||
property string name: ""
|
||||
property string author: ""
|
||||
|
@ -72,43 +72,6 @@ ModalPopup {
|
|||
anchors.fill: parent
|
||||
anchors.topMargin: Style.current.padding
|
||||
packId: stickerPackDetailsPopup.packId
|
||||
Component {
|
||||
id: stickerPackPurchaseModal
|
||||
SendModal {
|
||||
id: buyStickersPackModal
|
||||
interactive: false
|
||||
store: stickerPackDetailsPopup.transactionStore
|
||||
preSelectedSendType: Constants.SendType.StickersBuy
|
||||
preSelectedRecipient: stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
|
||||
preDefinedAmountToSend: LocaleUtils.numberToLocaleString(parseFloat(price))
|
||||
preSelectedHoldingID: {
|
||||
let token = SQUtils.ModelUtils.getByKey(stickerPackDetailsPopup.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", stickerPackDetailsPopup.store.stickersStore.getStatusTokenKey())
|
||||
return !!token && !!token.symbol ? token.symbol : ""
|
||||
}
|
||||
preSelectedHoldingType: Constants.TokenType.ERC20
|
||||
|
||||
Connections {
|
||||
target: stickerPackDetailsPopup.store.stickersStore.stickersModule
|
||||
function onTransactionWasSent(chainId: int, txHash: string, error: string) {
|
||||
if (!!error) {
|
||||
if (error.includes(Constants.walletSection.cancelledMessage)) {
|
||||
return
|
||||
}
|
||||
buyStickersPackModal.sendingError.text = error
|
||||
return buyStickersPackModal.sendingError.open()
|
||||
}
|
||||
let url = "%1/%2".arg(buyStickersPackModal.store.getEtherscanLink(chainId)).arg(txHash)
|
||||
Global.displayToastMessage(qsTr("Transaction pending..."),
|
||||
qsTr("View on etherscan"),
|
||||
"",
|
||||
true,
|
||||
Constants.ephemeralNotificationType.normal,
|
||||
url)
|
||||
buyStickersPackModal.close()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
footer: StatusStickerButton {
|
||||
|
@ -131,8 +94,20 @@ ModalPopup {
|
|||
onCancelClicked: function(){}
|
||||
onUpdateClicked: function(){}
|
||||
onBuyClicked: {
|
||||
Global.openPopup(stickerPackPurchaseModal)
|
||||
stickerPackDetailsPopup.buyClicked(packId)
|
||||
const token = SQUtils.ModelUtils.getByKey(stickerPackDetailsPopup.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", stickerPackDetailsPopup.store.stickersStore.getStatusTokenKey())
|
||||
|
||||
stickerPackDetailsPopup.sendModalPopup.interactive = false
|
||||
stickerPackDetailsPopup.sendModalPopup.preSelectedRecipient = stickerPackDetailsPopup.store.stickersStore.getStickersMarketAddress()
|
||||
stickerPackDetailsPopup.sendModalPopup.preSelectedRecipientType = Helpers.RecipientAddressObjectType.Address
|
||||
stickerPackDetailsPopup.sendModalPopup.preSelectedHoldingID = !!token && !!token.symbol ? token.symbol : ""
|
||||
stickerPackDetailsPopup.sendModalPopup.preSelectedHoldingType = Constants.TokenType.ERC20
|
||||
stickerPackDetailsPopup.sendModalPopup.preSelectedSendType = Constants.SendType.StickersBuy
|
||||
stickerPackDetailsPopup.sendModalPopup.preDefinedAmountToSend = LocaleUtils.numberToLocaleString(parseFloat(stickerPackDetailsPopup.price))
|
||||
stickerPackDetailsPopup.sendModalPopup.preSelectedChainId = stickerPackDetailsPopup.store.appNetworkId
|
||||
stickerPackDetailsPopup.sendModalPopup.stickersPackId = stickerPackDetailsPopup.packId
|
||||
stickerPackDetailsPopup.sendModalPopup.open()
|
||||
|
||||
stickerPackDetailsPopup.buyClicked(stickerPackDetailsPopup.packId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ Popup {
|
|||
id: root
|
||||
|
||||
property ChatStores.RootStore store
|
||||
required property TransactionStore transactionStore
|
||||
required property WalletAssetsStore walletAssetsStore
|
||||
required property var sendModalPopup
|
||||
|
||||
property alias isWalletEnabled: stickerMarket.isWalletEnabled
|
||||
|
||||
|
@ -102,8 +102,8 @@ Popup {
|
|||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
store: root.store
|
||||
transactionStore: root.transactionStore
|
||||
walletAssetsStore: root.walletAssetsStore
|
||||
sendModalPopup: root.sendModalPopup
|
||||
stickerPacks: d.stickerPackList
|
||||
packId: stickerPackListView.selectedPackId
|
||||
marketVisible: d.stickerPacksLoaded && d.online
|
||||
|
|
Loading…
Reference in New Issue