fix: sweep reopens bag correctly (#5430)

This commit is contained in:
Jack Short 2022-11-29 11:59:04 -05:00 committed by GitHub
parent f373a52da4
commit e9dd0c90e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -168,6 +168,7 @@ export const Sweep = ({ contractAddress, minPrice, maxPrice }: SweepProps) => {
const removeAssetsFromBag = useBag((state) => state.removeAssetsFromBag) const removeAssetsFromBag = useBag((state) => state.removeAssetsFromBag)
const itemsInBag = useBag((state) => state.itemsInBag) const itemsInBag = useBag((state) => state.itemsInBag)
const lockSweepItems = useBag((state) => state.lockSweepItems) const lockSweepItems = useBag((state) => state.lockSweepItems)
const setBagExpanded = useBag((state) => state.setBagExpanded)
const traits = useCollectionFilters((state) => state.traits) const traits = useCollectionFilters((state) => state.traits)
const markets = useCollectionFilters((state) => state.markets) const markets = useCollectionFilters((state) => state.markets)
@ -279,6 +280,8 @@ export const Sweep = ({ contractAddress, minPrice, maxPrice }: SweepProps) => {
const handleSweep = (value: number) => { const handleSweep = (value: number) => {
if (sortedAssets) { if (sortedAssets) {
if (isItemsToggled) { if (isItemsToggled) {
if (sweepItemsInBag.length === 0 && value > 0) setBagExpanded({ bagExpanded: true })
if (sweepItemsInBag.length < value) { if (sweepItemsInBag.length < value) {
addAssetsToBag(sortedAssets.slice(sweepItemsInBag.length, value), true) addAssetsToBag(sortedAssets.slice(sweepItemsInBag.length, value), true)
} else { } else {
@ -302,6 +305,7 @@ export const Sweep = ({ contractAddress, minPrice, maxPrice }: SweepProps) => {
} }
if (wishAssets.length > 0) { if (wishAssets.length > 0) {
if (sweepItemsInBag.length === 0) setBagExpanded({ bagExpanded: true })
addAssetsToBag(wishAssets, true) addAssetsToBag(wishAssets, true)
} }
} else { } else {