Skip to content

Commit

Permalink
Merge pull request #7545 from newraina/offer-showing-as-expired
Browse files Browse the repository at this point in the history
fix: offer showing as expired on incoming offers page
  • Loading branch information
roiLeo authored Oct 10, 2023
2 parents fab5d87 + 8f55aa8 commit 2b69820
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 4 additions & 2 deletions components/bsx/Offer/MyOffer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ import { notificationTypes, showNotification } from '@/utils/notification'
import { tokenIdToRoute } from '@/components/unique/utils'
import { timeAgo } from '@/components/collection/utils/timeAgo'
import { formatBsxBalanceToNumber } from '@/utils/format/balance'
import { formatSecondsToDuration } from '@/utils/format/time'
import { AllOfferStatusType } from '@/utils/offerStatus'
import acceptableOfferByCurrentOwner from '@/queries/subsquid/bsx/acceptableOfferByCurrentOwner.graphql'
Expand Down Expand Up @@ -217,11 +218,12 @@ const displayOffers = (offers: Offer[]) => {
}))
}
const currentBlock = ref(async () => {
const currentBlock = ref(0)
onMounted(async () => {
const { apiInstance } = useApi()
const api = await apiInstance.value
const block = await api.rpc.chain.getHeader()
return block.number.toNumber()
currentBlock.value = block.number.toNumber()
})
const calcSecondsToBlock = (block: number): number => {
Expand Down
5 changes: 3 additions & 2 deletions components/bsx/Offer/OfferTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,12 @@ watch(currentPage, (val) => {
replaceUrl({ page: String(val) })
})
const currentBlock = ref(async () => {
const currentBlock = ref(0)
onMounted(async () => {
const { apiInstance } = useApi()
const api = await apiInstance.value
const block = await api.rpc.chain.getHeader()
return block.number.toNumber()
currentBlock.value = block.number.toNumber()
})
const getUniqType = (offers: Offer[]) => {
Expand Down
11 changes: 9 additions & 2 deletions components/bsx/Offer/OffersUserTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ import { tokenIdToRoute } from '@/components/unique/utils'
import { formatBsxBalanceToNumber } from '@/utils/format/balance'
import { notificationTypes, showNotification } from '@/utils/notification'
import { AllOfferStatusType } from '@/utils/offerStatus'
import { formatSecondsToDuration } from '@/utils/format/time'
import { formatDistanceToNow } from 'date-fns'
import { Offer } from './types'
Expand Down Expand Up @@ -172,13 +173,19 @@ const getUniqType = () => {
return [{ type: AllOfferStatusType.ALL, value: 'All' }, ...singleEventList]
}
const currentBlock = ref(async () => {
const currentBlock = ref(0)
onMounted(async () => {
const { apiInstance } = useApi()
const api = await apiInstance.value
const block = await api.rpc.chain.getHeader()
return block.number.toNumber()
currentBlock.value = block.number.toNumber()
})
const calcSecondsToBlock = (block: number): number => {
const secondsForEachBlock = 12
return secondsForEachBlock * (block - currentBlock.value)
}
const calcExpirationTime = (expirationBlock: number): string => {
if (currentBlock.value === 0) {
return 'computing'
Expand Down

0 comments on commit 2b69820

Please sign in to comment.