Skip to content

Commit

Permalink
ui: always display FB utxos with lock icon in JarDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
theborakompanioni committed Nov 2, 2022
1 parent d3eb667 commit 0ada0bb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions src/components/jar_details/UtxoList.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
margin-bottom: 1px;
}

.utxoList .frozenLockedTag > .iconFrozen {
margin-bottom: 2px;
.utxoList .utxoIcon > .iconFrozen {
margin-bottom: 1px;
}

.utxoList .frozenLockedTag > .iconLocked {
.utxoList .utxoIcon > .iconLocked {
margin-bottom: 3px;
}

Expand Down
21 changes: 12 additions & 9 deletions src/components/jar_details/UtxoList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,15 @@ const UtxoList = ({ utxos, walletInfo, selectState, setSelectedUtxoIds, setDetai
array.sort((a, b) => {
const aUtxo = toUtxo(a)
const bUtxo = toUtxo(b)
if (fb.utxo.isLocked(aUtxo) && !fb.utxo.isLocked(bUtxo)) return -1
if (!fb.utxo.isLocked(aUtxo) && fb.utxo.isLocked(bUtxo)) return 1
if (fb.utxo.isLocked(aUtxo) && fb.utxo.isLocked(bUtxo)) return 0
const aLocked = fb.utxo.isLocked(aUtxo)
const bLocked = fb.utxo.isLocked(bUtxo)

if (aLocked && !bLocked) return -1
if (!aLocked && bLocked) return 1
if (aLocked && bLocked) return aUtxo.value - bUtxo.value
if (aUtxo.frozen && !bUtxo.frozen) return -1
if (!aUtxo.frozen && bUtxo.frozen) return 1
if (aUtxo.frozen && bUtxo.frozen) return 0
if (aUtxo.frozen && bUtxo.frozen) return aUtxo.value - bUtxo.value
return 0
}),
[SORT_KEYS.value]: (array) => array.sort((a, b) => a.value - b.value),
Expand All @@ -184,16 +187,16 @@ const UtxoList = ({ utxos, walletInfo, selectState, setSelectedUtxoIds, setDetai
}
)

const frozenOrLockedIcon = (utxo: Utxo) => {
if (fb.utxo.isLocked(utxo)) {
const utxoIcon = (utxo: Utxo) => {
if (fb.utxo.isFidelityBond(utxo)) {
return (
<div className={styles.frozenLockedTag}>
<div className={styles.utxoIcon}>
<Sprite className={styles.iconLocked} symbol="timelock" width="20" height="20" />
</div>
)
} else if (utxo.frozen) {
return (
<div className={styles.frozenLockedTag}>
<div className={styles.utxoIcon}>
<Sprite className={styles.iconFrozen} symbol="snowflake" width="20" height="20" />
</div>
)
Expand Down Expand Up @@ -236,7 +239,7 @@ const UtxoList = ({ utxos, walletInfo, selectState, setSelectedUtxoIds, setDetai
return (
<Row key={item.id} item={item}>
<CellSelect item={item} />
<Cell>{frozenOrLockedIcon(utxo)}</Cell>
<Cell>{utxoIcon(utxo)}</Cell>
<Cell>
<Balance
valueString={utxo.value.toString()}
Expand Down

0 comments on commit 0ada0bb

Please sign in to comment.