fix: oldObj should not overwrite properties

This commit is contained in:
Vlad Stan 2022-11-24 11:39:35 +02:00
parent a8d4835b74
commit 4b4f18fad5

View File

@ -14,15 +14,14 @@ const retryWithDelay = async function (fn, retryCount = 0) {
}
const mapCharge = (obj, oldObj = {}) => {
const charge = {...obj, ...oldObj}
const charge = {...oldObj, ...obj}
charge.progress = obj.time_left < 0 ? 1 : 1 - obj.time_left / obj.time
charge.time = minutesToTime(obj.time)
charge.timeLeft = minutesToTime(obj.time_left)
charge.expanded = false
charge.displayUrl = ['/satspay/', obj.id].join('')
charge.expanded = oldObj.expanded
charge.expanded = oldObj.expanded || false
charge.pendingBalance = oldObj.pendingBalance || 0
return charge
}