mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
fix forever timeout for assets (#1445)
This commit is contained in:
parent
bf31cdfed5
commit
f0b22ee8e4
@ -152,14 +152,11 @@ function getAccessDetailsFromTokenPrice(
|
|||||||
timeout?: number
|
timeout?: number
|
||||||
): AccessDetails {
|
): AccessDetails {
|
||||||
const accessDetails = {} as AccessDetails
|
const accessDetails = {} as AccessDetails
|
||||||
if (
|
if (tokenPrice && tokenPrice.orders && tokenPrice.orders.length > 0) {
|
||||||
tokenPrice &&
|
|
||||||
timeout &&
|
|
||||||
tokenPrice.orders &&
|
|
||||||
tokenPrice.orders.length > 0
|
|
||||||
) {
|
|
||||||
const order = tokenPrice.orders[0]
|
const order = tokenPrice.orders[0]
|
||||||
accessDetails.isOwned = Date.now() / 1000 - order.createdTimestamp < timeout
|
// asset is owned if there is an order and asset has timeout 0 (forever) or if the condition is valid
|
||||||
|
accessDetails.isOwned =
|
||||||
|
timeout === 0 || Date.now() / 1000 - order.createdTimestamp < timeout
|
||||||
accessDetails.validOrderTx = order.tx
|
accessDetails.validOrderTx = order.tx
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ export default function Download({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!asset?.accessDetails) return
|
if (!asset?.accessDetails) return
|
||||||
|
|
||||||
setIsOwned(asset?.accessDetails?.isOwned)
|
asset?.accessDetails?.isOwned && setIsOwned(asset?.accessDetails?.isOwned)
|
||||||
|
asset?.accessDetails?.validOrderTx &&
|
||||||
setValidOrderTx(asset?.accessDetails?.validOrderTx)
|
setValidOrderTx(asset?.accessDetails?.validOrderTx)
|
||||||
|
|
||||||
// get full price and fees
|
// get full price and fees
|
||||||
@ -166,7 +167,6 @@ export default function Download({
|
|||||||
if (!orderTx) {
|
if (!orderTx) {
|
||||||
throw new Error()
|
throw new Error()
|
||||||
}
|
}
|
||||||
|
|
||||||
setIsOwned(true)
|
setIsOwned(true)
|
||||||
setValidOrderTx(orderTx.transactionHash)
|
setValidOrderTx(orderTx.transactionHash)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user