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
|
||||
): AccessDetails {
|
||||
const accessDetails = {} as AccessDetails
|
||||
if (
|
||||
tokenPrice &&
|
||||
timeout &&
|
||||
tokenPrice.orders &&
|
||||
tokenPrice.orders.length > 0
|
||||
) {
|
||||
if (tokenPrice && tokenPrice.orders && tokenPrice.orders.length > 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
|
||||
}
|
||||
|
||||
|
@ -53,8 +53,9 @@ export default function Download({
|
||||
useEffect(() => {
|
||||
if (!asset?.accessDetails) return
|
||||
|
||||
setIsOwned(asset?.accessDetails?.isOwned)
|
||||
setValidOrderTx(asset?.accessDetails?.validOrderTx)
|
||||
asset?.accessDetails?.isOwned && setIsOwned(asset?.accessDetails?.isOwned)
|
||||
asset?.accessDetails?.validOrderTx &&
|
||||
setValidOrderTx(asset?.accessDetails?.validOrderTx)
|
||||
|
||||
// get full price and fees
|
||||
async function init() {
|
||||
@ -166,7 +167,6 @@ export default function Download({
|
||||
if (!orderTx) {
|
||||
throw new Error()
|
||||
}
|
||||
|
||||
setIsOwned(true)
|
||||
setValidOrderTx(orderTx.transactionHash)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user