Commit 48883cce authored by Charles Bachmeier's avatar Charles Bachmeier Committed by GitHub

fix: Can remove marketplace or listing from modal (#5362)

* removing asset doesn't change other listings

* remove marketplace from modal removes asset

* working multiple markets

* better fix

* track signed listing

* simpler solution

* remove unused field

* correct transition
Co-authored-by: default avatarCharles Bachmeier <charlie@genie.xyz>
parent 3d820d39
......@@ -51,9 +51,7 @@ export const ListingButton = ({ onClick, buttonText, showWarningOverride = false
listingsAboveSellOrderFloor,
invalidPrices,
] = useMemo(() => {
const noMarketplacesSelected = sellAssets.some(
(asset: WalletAsset) => asset.marketplaces === undefined || asset.marketplaces.length === 0
)
const noMarketplacesSelected = sellAssets.some((asset: WalletAsset) => asset.marketplaces === undefined)
const missingExpiration = sellAssets.some((asset) => {
return asset.expirationTime != null && asset.expirationTime * 1000 - Date.now() < ms`60 seconds`
})
......
......@@ -147,6 +147,7 @@ export const getListings = (sellAssets: WalletAsset[]): [CollectionRow[], Listin
status: ListingStatus.DEFINED,
asset,
marketplace,
price: asset.newListings?.find((listing) => listing.marketplace.name === marketplace.name)?.price,
}
newListings.push(newListing)
if (
......
......@@ -33,7 +33,32 @@ export const useNFTList = create<NFTListState>()(
}),
setListings: (listings) =>
set(() => {
return { listings }
const updatedListings = listings.map((listing) => {
const oldStatus = get().listings.find(
(oldListing) =>
oldListing.asset.asset_contract.address === listing.asset.asset_contract.address &&
oldListing.asset.tokenId === listing.asset.tokenId &&
oldListing.marketplace.name === listing.marketplace.name &&
oldListing.price === listing.price
)?.status
const status = () => {
switch (oldStatus) {
case ListingStatus.APPROVED:
return ListingStatus.APPROVED
case ListingStatus.FAILED:
return listing.status === ListingStatus.SIGNING ? ListingStatus.SIGNING : ListingStatus.FAILED
default:
return listing.status
}
}
return {
...listing,
status: status(),
}
})
return {
listings: updatedListings,
}
}),
setCollectionsRequiringApproval: (collections) =>
set(() => {
......
......@@ -104,6 +104,7 @@ export interface AssetRow {
export interface ListingRow extends AssetRow {
asset: WalletAsset
marketplace: ListingMarket
price?: number
}
export interface CollectionRow extends AssetRow {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment