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
|
contactsStore: root.contactsStore
|
||||||
sharedRootStore: root.sharedRootStore
|
sharedRootStore: root.sharedRootStore
|
||||||
rootStore: root.rootStore
|
rootStore: root.rootStore
|
||||||
transactionStore: root.transactionStore
|
|
||||||
createChatPropertiesStore: root.createChatPropertiesStore
|
createChatPropertiesStore: root.createChatPropertiesStore
|
||||||
communitiesStore: root.communitiesStore
|
communitiesStore: root.communitiesStore
|
||||||
walletAssetsStore: root.walletAssetsStore
|
walletAssetsStore: root.walletAssetsStore
|
||||||
currencyStore: root.currencyStore
|
currencyStore: root.currencyStore
|
||||||
|
sendModalPopup: root.sendModalPopup
|
||||||
sectionItemModel: root.sectionItemModel
|
sectionItemModel: root.sectionItemModel
|
||||||
amIMember: sectionItem.amIMember
|
amIMember: sectionItem.amIMember
|
||||||
amISectionAdmin: root.sectionItemModel.memberRole === Constants.memberRole.owner ||
|
amISectionAdmin: root.sectionItemModel.memberRole === Constants.memberRole.owner ||
|
||||||
|
|
|
@ -283,6 +283,8 @@ QtObject {
|
||||||
|
|
||||||
property var mainModuleInst: mainModule
|
property var mainModuleInst: mainModule
|
||||||
|
|
||||||
|
readonly property string appNetworkId: mainModuleInst.appNetworkId
|
||||||
|
|
||||||
property var communitiesModuleInst: communitiesModule
|
property var communitiesModuleInst: communitiesModule
|
||||||
property var communitiesList: communitiesModuleInst.model
|
property var communitiesList: communitiesModuleInst.model
|
||||||
|
|
||||||
|
|
|
@ -44,11 +44,11 @@ StatusSectionLayout {
|
||||||
|
|
||||||
property SharedStores.RootStore sharedRootStore
|
property SharedStores.RootStore sharedRootStore
|
||||||
property ChatStores.RootStore rootStore
|
property ChatStores.RootStore rootStore
|
||||||
required property SendStores.TransactionStore transactionStore
|
|
||||||
property ChatStores.CreateChatPropertiesStore createChatPropertiesStore
|
property ChatStores.CreateChatPropertiesStore createChatPropertiesStore
|
||||||
property CommunitiesStores.CommunitiesStore communitiesStore
|
property CommunitiesStores.CommunitiesStore communitiesStore
|
||||||
required property WalletStore.WalletAssetsStore walletAssetsStore
|
required property WalletStore.WalletAssetsStore walletAssetsStore
|
||||||
required property SharedStores.CurrenciesStore currencyStore
|
required property SharedStores.CurrenciesStore currencyStore
|
||||||
|
required property var sendModalPopup
|
||||||
property var sectionItemModel
|
property var sectionItemModel
|
||||||
|
|
||||||
property var emojiPopup
|
property var emojiPopup
|
||||||
|
@ -307,8 +307,8 @@ StatusSectionLayout {
|
||||||
Component {
|
Component {
|
||||||
id: statusStickerPackClickPopup
|
id: statusStickerPackClickPopup
|
||||||
StatusStickerPackClickPopup{
|
StatusStickerPackClickPopup{
|
||||||
transactionStore: root.transactionStore
|
|
||||||
walletAssetsStore: root.walletAssetsStore
|
walletAssetsStore: root.walletAssetsStore
|
||||||
|
sendModalPopup: root.sendModalPopup
|
||||||
onClosed: {
|
onClosed: {
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
|
@ -651,8 +651,8 @@ Item {
|
||||||
active: appMain.rootStore.mainModuleInst.sectionsLoaded
|
active: appMain.rootStore.mainModuleInst.sectionsLoaded
|
||||||
sourceComponent: StatusStickersPopup {
|
sourceComponent: StatusStickersPopup {
|
||||||
store: appMain.rootChatStore
|
store: appMain.rootChatStore
|
||||||
transactionStore: appMain.transactionStore
|
|
||||||
walletAssetsStore: appMain.walletAssetsStore
|
walletAssetsStore: appMain.walletAssetsStore
|
||||||
|
sendModalPopup: sendModal
|
||||||
|
|
||||||
isWalletEnabled: appMain.rootStore.profileSectionStore.profileStore.isWalletEnabled
|
isWalletEnabled: appMain.rootStore.profileSectionStore.profileStore.isWalletEnabled
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,8 +25,8 @@ Item {
|
||||||
|
|
||||||
property ChatStores.RootStore store
|
property ChatStores.RootStore store
|
||||||
property var stickerPacks: ChatStores.StickerPackData {}
|
property var stickerPacks: ChatStores.StickerPackData {}
|
||||||
required property TransactionStore transactionStore
|
|
||||||
required property WalletAssetsStore walletAssetsStore
|
required property WalletAssetsStore walletAssetsStore
|
||||||
|
required property var sendModalPopup
|
||||||
property string packId
|
property string packId
|
||||||
property bool marketVisible
|
property bool marketVisible
|
||||||
property bool isWalletEnabled
|
property bool isWalletEnabled
|
||||||
|
@ -38,6 +38,26 @@ Item {
|
||||||
signal updateClicked(string packId)
|
signal updateClicked(string packId)
|
||||||
signal buyClicked(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 {
|
StatusGridView {
|
||||||
id: availableStickerPacks
|
id: availableStickerPacks
|
||||||
objectName: "stickerMarketStatusGridView"
|
objectName: "stickerMarketStatusGridView"
|
||||||
|
@ -154,7 +174,7 @@ Item {
|
||||||
onCancelClicked: root.cancelClicked(packId)
|
onCancelClicked: root.cancelClicked(packId)
|
||||||
onUpdateClicked: root.updateClicked(packId)
|
onUpdateClicked: root.updateClicked(packId)
|
||||||
onBuyClicked: {
|
onBuyClicked: {
|
||||||
Global.openPopup(stickerPackPurchaseModal, {price, packId})
|
d.runSendModal(price, packId)
|
||||||
root.buyClicked(packId)
|
root.buyClicked(packId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,7 +207,7 @@ Item {
|
||||||
onCancelClicked: root.cancelClicked(packId)
|
onCancelClicked: root.cancelClicked(packId)
|
||||||
onUpdateClicked: root.updateClicked(packId)
|
onUpdateClicked: root.updateClicked(packId)
|
||||||
onBuyClicked: {
|
onBuyClicked: {
|
||||||
Global.openPopup(stickerPackPurchaseModal, {price, packId})
|
d.runSendModal(price, packId)
|
||||||
root.buyClicked(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 {
|
Item {
|
||||||
id: footer
|
id: footer
|
||||||
height: 44
|
height: 44
|
||||||
|
|
|
@ -25,8 +25,8 @@ ModalPopup {
|
||||||
property string packId
|
property string packId
|
||||||
|
|
||||||
property ChatStores.RootStore store
|
property ChatStores.RootStore store
|
||||||
required property TransactionStore transactionStore
|
|
||||||
required property WalletAssetsStore walletAssetsStore
|
required property WalletAssetsStore walletAssetsStore
|
||||||
|
required property var sendModalPopup
|
||||||
property string thumbnail: ""
|
property string thumbnail: ""
|
||||||
property string name: ""
|
property string name: ""
|
||||||
property string author: ""
|
property string author: ""
|
||||||
|
@ -72,43 +72,6 @@ ModalPopup {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.topMargin: Style.current.padding
|
anchors.topMargin: Style.current.padding
|
||||||
packId: stickerPackDetailsPopup.packId
|
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 {
|
footer: StatusStickerButton {
|
||||||
|
@ -131,8 +94,20 @@ ModalPopup {
|
||||||
onCancelClicked: function(){}
|
onCancelClicked: function(){}
|
||||||
onUpdateClicked: function(){}
|
onUpdateClicked: function(){}
|
||||||
onBuyClicked: {
|
onBuyClicked: {
|
||||||
Global.openPopup(stickerPackPurchaseModal)
|
const token = SQUtils.ModelUtils.getByKey(stickerPackDetailsPopup.walletAssetsStore.groupedAccountAssetsModel, "tokensKey", stickerPackDetailsPopup.store.stickersStore.getStatusTokenKey())
|
||||||
stickerPackDetailsPopup.buyClicked(packId)
|
|
||||||
|
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
|
id: root
|
||||||
|
|
||||||
property ChatStores.RootStore store
|
property ChatStores.RootStore store
|
||||||
required property TransactionStore transactionStore
|
|
||||||
required property WalletAssetsStore walletAssetsStore
|
required property WalletAssetsStore walletAssetsStore
|
||||||
|
required property var sendModalPopup
|
||||||
|
|
||||||
property alias isWalletEnabled: stickerMarket.isWalletEnabled
|
property alias isWalletEnabled: stickerMarket.isWalletEnabled
|
||||||
|
|
||||||
|
@ -102,8 +102,8 @@ Popup {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
store: root.store
|
store: root.store
|
||||||
transactionStore: root.transactionStore
|
|
||||||
walletAssetsStore: root.walletAssetsStore
|
walletAssetsStore: root.walletAssetsStore
|
||||||
|
sendModalPopup: root.sendModalPopup
|
||||||
stickerPacks: d.stickerPackList
|
stickerPacks: d.stickerPackList
|
||||||
packId: stickerPackListView.selectedPackId
|
packId: stickerPackListView.selectedPackId
|
||||||
marketVisible: d.stickerPacksLoaded && d.online
|
marketVisible: d.stickerPacksLoaded && d.online
|
||||||
|
|
Loading…
Reference in New Issue