Skip to content

Commit

Permalink
refactor: making offer
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarsen136 committed Aug 19, 2024
1 parent b4cdef7 commit eca9f9c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 120 deletions.
2 changes: 1 addition & 1 deletion components/common/CartItemDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="flex">
<div>
<BaseMediaItem
v-if="nft?.mediaUrl"
v-if="nft.mediaUrl"
class="border border-k-shade image is-48x48"
:class="{ 'opacity-50': discarded }"
:alt="nft?.name"
Expand Down
24 changes: 2 additions & 22 deletions components/common/listingCart/ListingCartModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,9 @@ const { chainSymbol, decimals } = useChain()
const fixedPrice = ref()
const floorPricePercentAdjustment = ref()
const autoTeleport = ref(false)
const autoTeleportButton = ref()
const itemCount = ref(listingCartStore.count)
const items = ref<ListCartItem[]>([])
const autoTeleportLoaded = ref(false)
const isSuccessModalOpen = computed(
() => Boolean(items.value.length) && isTransactionSuccessful.value,
Expand Down Expand Up @@ -188,10 +186,7 @@ const getAction = (items: ListCartItem[]): Actions => {
}
}
const { action } = useAutoTeleportActionButton({
autoTeleport,
autoTeleportButton,
autoTeleportLoaded,
const { action, autoTeleport, autoTeleportButton, autoTeleportLoaded } = useAutoTeleportActionButton({
getActionFn: () => getAction(listingCartStore.itemsInChain),
})
Expand Down Expand Up @@ -329,21 +324,6 @@ watch(
},
)
// watch(
// () => autoTeleportButton.value?.isReady,
// () => {
// if (autoTeleportButton.value?.isReady && !autoTeleportLoaded.value) {
// autoTeleportLoaded.value = true
// }
// },
// )
// watchSyncEffect(() => {
// if (!autoTeleport.value) {
// action.value = getAction(listingCartStore.itemsInChain)
// }
// })
const closeListingCartModal = () =>
(preferencesStore.listingCartModalOpen = false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,10 @@ const openOfferModal = () => {
preferencesStore.setMakeOfferModalOpen(true)
}
watch(
() => preferencesStore.makeOfferModalOpen,
(isOpen) => {
if (!isOpen) {
onOfferModalClose()
}
},
)
const onOfferModalClose = () => {
setTimeout(() => {
makeOfferStore.clear()
}, 500) // wait for modal animation
}
useModalIsOpenTracker({
isOpen: computed(() => preferencesStore.makeOfferModalOpen),
onChange: () => makeOfferStore.clear(),
})
</script>

<style lang="scss" scoped>
Expand Down
9 changes: 1 addition & 8 deletions components/offer/MakeOffer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,8 @@ const { isTransactionSuccessful } = useTransactionSuccessful({
const { decimals } = useChain()
const { $i18n } = useNuxtApp()
const autoTeleport = ref(false)
const autoTeleportButton = ref()
const itemCount = ref(offerStore.count)
const items = ref<MakingOfferItem[]>([])
const autoTeleportLoaded = ref(false)
const isSuccessModalOpen = computed(
() => Boolean(items.value.length) && isTransactionSuccessful.value,
Expand All @@ -130,10 +126,7 @@ const getAction = (items: MakingOfferItem[]): Actions => {
}
}
const { action } = useAutoTeleportActionButton({
autoTeleport,
autoTeleportButton,
autoTeleportLoaded,
const { action, autoTeleport, autoTeleportButton, autoTeleportLoaded } = useAutoTeleportActionButton({
getActionFn: () => getAction(offerStore.itemsInChain),
})
Expand Down
72 changes: 0 additions & 72 deletions components/offer/MakingOfferItemDetails.vue

This file was deleted.

9 changes: 6 additions & 3 deletions composables/autoTeleport/useAutoTeleportActionButton.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Actions } from '@/composables/transaction/types'

export default ({
autoTeleport,
autoTeleportButton,
autoTeleportLoaded,
getActionFn,
}) => {
const autoTeleport = ref(false)
const autoTeleportButton = ref()
const autoTeleportLoaded = ref(false)
const action = ref<Actions>(emptyObject<Actions>())

watch(
Expand All @@ -25,5 +25,8 @@ export default ({

return {
action,
autoTeleport,
autoTeleportButton,
autoTeleportLoaded,
}
}

0 comments on commit eca9f9c

Please sign in to comment.