forked from Qortal/qortal-ui
Filtering offers based on foreign chain
fixed an issue with websocket offers being shown even though it's not the correct selected coin
This commit is contained in:
parent
ecf387f034
commit
669f652f87
@ -1199,106 +1199,142 @@ class TradePortal extends LitElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processOfferingTrade(offer) {
|
processOfferingTrade(offer) {
|
||||||
const offerItem = {
|
try{
|
||||||
...offer,
|
if(this.listedCoins.get(offer.foreignBlockchain).name!=''){//check if the foreignBlockchain value is part of supported blockchains
|
||||||
qortAmount: parseFloat(offer.qortAmount),
|
const offerItem = {
|
||||||
price: parseFloat(offer.foreignAmount) / parseFloat(offer.qortAmount),
|
...offer,
|
||||||
|
qortAmount: parseFloat(offer.qortAmount),
|
||||||
|
price: parseFloat(offer.foreignAmount) / parseFloat(offer.qortAmount),
|
||||||
|
}
|
||||||
|
const addOffer = () => {
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).openOrders.unshift(offerItem)
|
||||||
|
}
|
||||||
|
const initOffer = () => {
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).openOrders.push(offerItem)
|
||||||
|
}
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).openOrders.length === 0 ? initOffer() : addOffer()
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? this._openOrdersGrid.clearCache() : null
|
||||||
|
}
|
||||||
|
}catch(e){
|
||||||
|
console.log("Error adding offer from "+offer.foreignBlockchain)
|
||||||
}
|
}
|
||||||
const addOffer = () => {
|
|
||||||
this.listedCoins.get(this.selectedCoin).openOrders.unshift(offerItem)
|
|
||||||
}
|
|
||||||
const initOffer = () => {
|
|
||||||
this.listedCoins.get(this.selectedCoin).openOrders.push(offerItem)
|
|
||||||
}
|
|
||||||
this.listedCoins.get(this.selectedCoin).openOrders.length === 0 ? initOffer() : addOffer()
|
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._openOrdersGrid.clearCache() : null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processRedeemedTrade(offer) {
|
processRedeemedTrade(offer) {
|
||||||
// If trade is mine, add it to my historic trades and also add it to historic trades
|
try{
|
||||||
if (offer.qortalCreator === this.selectedAddress.address) {
|
if(this.listedCoins.get(offer.foreignBlockchain).name!=''){//check if the foreignBlockchain value is part of supported blockchains
|
||||||
// Check and Update Wallet Balance
|
|
||||||
if (this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1) {
|
// If trade is mine, add it to my historic trades and also add it to historic trades
|
||||||
this.updateWalletBalance()
|
if (offer.qortalCreator === this.selectedAddress.address) {
|
||||||
|
// Check and Update Wallet Balance
|
||||||
|
if (this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1) {
|
||||||
|
this.updateWalletBalance()
|
||||||
|
}
|
||||||
|
const offerItem = {
|
||||||
|
...offer,
|
||||||
|
mode: 'SOLD',
|
||||||
|
}
|
||||||
|
// Add to my historic trades
|
||||||
|
this._myHistoricTradesGrid.items.unshift(offerItem)
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
||||||
|
} else if (offer.partnerQortalReceivingAddress === this.selectedAddress.address) {
|
||||||
|
// Check and Update Wallet Balance
|
||||||
|
if (this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1) {
|
||||||
|
this.updateWalletBalance()
|
||||||
|
}
|
||||||
|
const offerItem = {
|
||||||
|
...offer,
|
||||||
|
mode: 'BOUGHT',
|
||||||
|
}
|
||||||
|
// Add to my historic trades
|
||||||
|
this._myHistoricTradesGrid.items.unshift(offerItem)
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
||||||
|
}
|
||||||
|
// Add to historic trades
|
||||||
|
const addNewHistoricTrade = () => {
|
||||||
|
this._historicTradesGrid.items.unshift(offer)
|
||||||
|
this._historicTradesGrid.clearCache()
|
||||||
|
}
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? addNewHistoricTrade() : null
|
||||||
|
|
||||||
}
|
}
|
||||||
const offerItem = {
|
}catch(e){
|
||||||
...offer,
|
console.log("Error processing redeemed trade offer from "+offer.foreignBlockchain)
|
||||||
mode: 'SOLD',
|
|
||||||
}
|
|
||||||
// Add to my historic trades
|
|
||||||
this._myHistoricTradesGrid.items.unshift(offerItem)
|
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
|
||||||
} else if (offer.partnerQortalReceivingAddress === this.selectedAddress.address) {
|
|
||||||
// Check and Update Wallet Balance
|
|
||||||
if (this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1) {
|
|
||||||
this.updateWalletBalance()
|
|
||||||
}
|
|
||||||
const offerItem = {
|
|
||||||
...offer,
|
|
||||||
mode: 'BOUGHT',
|
|
||||||
}
|
|
||||||
// Add to my historic trades
|
|
||||||
this._myHistoricTradesGrid.items.unshift(offerItem)
|
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
|
||||||
}
|
}
|
||||||
// Add to historic trades
|
|
||||||
const addNewHistoricTrade = () => {
|
|
||||||
this._historicTradesGrid.items.unshift(offer)
|
|
||||||
this._historicTradesGrid.clearCache()
|
|
||||||
}
|
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? addNewHistoricTrade() : null
|
|
||||||
}
|
}
|
||||||
|
|
||||||
processTradingTrade(offer) {
|
processTradingTrade(offer) {
|
||||||
// Remove from open market orders
|
try{
|
||||||
if (offer.qortalCreator === this.selectedAddress.address && this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1) {
|
if(this.listedCoins.get(offer.foreignBlockchain).name!=''){//check if the foreignBlockchain value is part of supported blockchains
|
||||||
// Check and Update Wallet Balance
|
|
||||||
this.updateWalletBalance()
|
// Remove from open market orders
|
||||||
}
|
if (offer.qortalCreator === this.selectedAddress.address && this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1) {
|
||||||
this._openOrdersGrid.items.forEach((item, index) => {
|
// Check and Update Wallet Balance
|
||||||
if (item.qortalAtAddress === offer.qortalAtAddress) {
|
this.updateWalletBalance()
|
||||||
this._openOrdersGrid.items.splice(index, 1)
|
}
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._openOrdersGrid.clearCache() : null
|
this._openOrdersGrid.items.forEach((item, index) => {
|
||||||
|
if (item.qortalAtAddress === offer.qortalAtAddress) {
|
||||||
|
this._openOrdersGrid.items.splice(index, 1)
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? this._openOrdersGrid.clearCache() : null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).openOrders = this.listedCoins.get(offer.foreignBlockchain).openOrders.filter((order) => order.qortalAtAddress !== offer.qortalAtAddress)
|
||||||
}
|
}
|
||||||
})
|
}catch(e){
|
||||||
this.listedCoins.get(this.selectedCoin).openOrders = this.listedCoins.get(this.selectedCoin).openOrders.filter((order) => order.qortalAtAddress !== offer.qortalAtAddress)
|
console.log("Error processing trading trade offer from "+offer.foreignBlockchain)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processRefundedTrade(offer) {
|
processRefundedTrade(offer) {
|
||||||
if (offer.qortalCreator === this.selectedAddress.address) {
|
try{
|
||||||
// Check and Update Wallet Balance
|
if(this.listedCoins.get(offer.foreignBlockchain).name!=''){//check if the foreignBlockchain value is part of supported blockchains
|
||||||
if (this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1) {
|
|
||||||
this.updateWalletBalance()
|
if (offer.qortalCreator === this.selectedAddress.address) {
|
||||||
|
// Check and Update Wallet Balance
|
||||||
|
if (this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1) {
|
||||||
|
this.updateWalletBalance()
|
||||||
|
}
|
||||||
|
// Add to my historic trades
|
||||||
|
this._myHistoricTradesGrid.items.unshift(offer)
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
||||||
}
|
}
|
||||||
// Add to my historic trades
|
|
||||||
this._myHistoricTradesGrid.items.unshift(offer)
|
}
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
}catch(e){
|
||||||
|
console.log("Error processing refunded trade offer from "+offer.foreignBlockchain)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processCancelledTrade(offer) {
|
processCancelledTrade(offer) {
|
||||||
if (offer.qortalCreator === this.selectedAddress.address) {
|
try{
|
||||||
// Check and Update Wallet Balance
|
if(this.listedCoins.get(offer.foreignBlockchain).name!=''){//check if the foreignBlockchain value is part of supported blockchains
|
||||||
if (this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1) {
|
|
||||||
this.updateWalletBalance()
|
if (offer.qortalCreator === this.selectedAddress.address) {
|
||||||
|
// Check and Update Wallet Balance
|
||||||
|
if (this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1) {
|
||||||
|
this.updateWalletBalance()
|
||||||
|
}
|
||||||
|
// Add to my historic trades
|
||||||
|
this._myHistoricTradesGrid.items.unshift(offer)
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
||||||
|
}
|
||||||
|
this._openOrdersGrid.items.forEach((item, index) => {
|
||||||
|
if (item.qortalAtAddress === offer.qortalAtAddress) {
|
||||||
|
this._openOrdersGrid.items.splice(index, 1)
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).tradeOffersSocketCounter > 1 ? this._openOrdersGrid.clearCache() : null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.listedCoins.get(offer.foreignBlockchain).openOrders = this.listedCoins.get(offer.foreignBlockchain).openOrders.filter((order) => order.qortalAtAddress !== offer.qortalAtAddress)
|
||||||
|
this._stuckOrdersGrid.items.forEach((item, index) => {
|
||||||
|
if (item.qortalAtAddress === offer.qortalAtAddress) {
|
||||||
|
this._stuckOrdersGrid.items.splice(index, 1)
|
||||||
|
this._stuckOrdersGrid.clearCache()
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
// Add to my historic trades
|
}catch(e){
|
||||||
this._myHistoricTradesGrid.items.unshift(offer)
|
console.log("Error processing cancelled trade offer from "+offer.foreignBlockchain)
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._myHistoricTradesGrid.clearCache() : null
|
|
||||||
}
|
}
|
||||||
this._openOrdersGrid.items.forEach((item, index) => {
|
|
||||||
if (item.qortalAtAddress === offer.qortalAtAddress) {
|
|
||||||
this._openOrdersGrid.items.splice(index, 1)
|
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._openOrdersGrid.clearCache() : null
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.listedCoins.get(this.selectedCoin).openOrders = this.listedCoins.get(this.selectedCoin).openOrders.filter((order) => order.qortalAtAddress !== offer.qortalAtAddress)
|
|
||||||
this._stuckOrdersGrid.items.forEach((item, index) => {
|
|
||||||
if (item.qortalAtAddress === offer.qortalAtAddress) {
|
|
||||||
this._stuckOrdersGrid.items.splice(index, 1)
|
|
||||||
this._stuckOrdersGrid.clearCache()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1314,7 +1350,6 @@ class TradePortal extends LitElement {
|
|||||||
offers.forEach((offer) => {
|
offers.forEach((offer) => {
|
||||||
if (offer.mode === 'OFFERING') {
|
if (offer.mode === 'OFFERING') {
|
||||||
this.processOfferingTrade(offer)
|
this.processOfferingTrade(offer)
|
||||||
this.listedCoins.get(this.selectedCoin).tradeOffersSocketCounter > 1 ? this._openOrdersGrid.clearCache() : null
|
|
||||||
} else if (offer.mode === 'REDEEMED') {
|
} else if (offer.mode === 'REDEEMED') {
|
||||||
this.processRedeemedTrade(offer)
|
this.processRedeemedTrade(offer)
|
||||||
} else if (offer.mode === 'TRADING') {
|
} else if (offer.mode === 'TRADING') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user