Changeset View
Changeset View
Standalone View
Standalone View
web/cashtab/src/hooks/useWallet.js
Show First 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | const haveUtxosChanged = (wallet, utxos, previousUtxos) => { | ||||
// then assume utxos have changed | // then assume utxos have changed | ||||
return true; | return true; | ||||
} | } | ||||
// return true for empty array, since this means you definitely do not want to skip the next API call | // return true for empty array, since this means you definitely do not want to skip the next API call | ||||
if (utxos && utxos.length === 0) { | if (utxos && utxos.length === 0) { | ||||
return true; | return true; | ||||
} | } | ||||
// If utxo set is in wallet object, use that to compare instead of previousUtxos | |||||
let previousUtxosToCompare; | |||||
if (wallet.state && wallet.state.utxos) { | |||||
previousUtxosToCompare = wallet.state.utxos; | |||||
} else { | |||||
previousUtxosToCompare = previousUtxos; | |||||
} | |||||
// Compare utxo sets | // Compare utxo sets | ||||
const utxoArraysUnchanged = _.isEqual(utxos, previousUtxos); | const utxoArraysUnchanged = _.isEqual(utxos, previousUtxosToCompare); | ||||
// If utxos are not the same as previousUtxos | // If utxos are not the same as previousUtxos | ||||
if (utxoArraysUnchanged) { | if (utxoArraysUnchanged) { | ||||
// then utxos have not changed | // then utxos have not changed | ||||
return false; | return false; | ||||
// otherwise, | // otherwise, | ||||
} else { | } else { | ||||
// utxos have changed | // utxos have changed | ||||
▲ Show 20 Lines • Show All 1,139 Lines • Show Last 20 Lines |