diff --git a/index.html b/index.html
index 3ac13d5..482ac00 100644
--- a/index.html
+++ b/index.html
@@ -668,6 +668,7 @@
}
await btcMortgage.lockCollateral(collateralLockID, borrower, lender, await floDapps.user.private)
notify('Collateral locked successfully', 'success')
+ await btcMortgage.readOutbox()
router.routeTo(location.hash)
} catch (err) {
notify(err, 'error')
@@ -697,8 +698,8 @@
let hasLockedCollateralForMoreThan24Hours = false
useEffect(() => {
if (isCoborrower && hasLockedCollateral && !hasIssuedLoan) {
- const currentTime = new Date().getTime()
- const timeDiff = currentTime - collateralLockAckTime
+ const timeDiff = Date.now() - collateralLockAckTime
+ console.log(timeDiff)
if (timeDiff > 86400000) {
hasLockedCollateralForMoreThan24Hours = true
}
@@ -775,21 +776,25 @@
${hasLockedCollateral ? html`
Collateral locked
- ${hasLockedCollateralForMoreThan24Hours && !hasRequestedCollateralRefund ? html`
-
- Loan has not been issued even after 24 hours of collateral lock.
- You can request for collateral refund.
-
-
+ ${hasLockedCollateralForMoreThan24Hours ? html`
+ ${hasRequestedCollateralRefund ? html`
+
Collateral refund requested. It'll be refunded within 24 hrs.
+ `: html`
+
+ Loan has not been issued even after 24 hours of collateral lock.
+ You can request for collateral refund.
+
+
+ `}
`: html`
-
Collateral refund requested. It'll be refunded within 24 hrs.
+
`}
`: html`
Waiting for collateral to be locked
diff --git a/scripts/btcMortgage.js b/scripts/btcMortgage.js
index 0021d81..5113ce8 100644
--- a/scripts/btcMortgage.js
+++ b/scripts/btcMortgage.js
@@ -915,6 +915,17 @@
})
}
+ btcMortgage.readOutbox = () => new Promise((resolve, reject) => {
+ compactIDB.readAllData("outbox")
+ .then(result => {
+ for (const key in result) {
+ result[key].message = floCloudAPI.util.decodeMessage(result[key].message);
+ }
+ resolve(result);
+ })
+ .catch(error => reject(error))
+ })
+
btcMortgage.viewMyOutbox = (callback = undefined) => { //view all inbox
return new Promise((resolve, reject) => {
let options = { senderID: floDapps.user.id }
@@ -922,13 +933,7 @@
options.callback = callback;
floCloudAPI.requestApplicationData(null, options)
.then(_ => {
- compactIDB.readAllData("outbox")
- .then(result => {
- for (const key in result) {
- result[key].message = floCloudAPI.util.decodeMessage(result[key].message);
- }
- resolve(result);
- })
+ btcMortgage.readOutbox().then(result => resolve(result))
.catch(error => reject(error))
})
.catch(error => {