fix npe opening deposit view without monero connection #431

This commit is contained in:
woodser 2023-08-09 09:21:53 -04:00
parent 7fc2f5de52
commit c193385475
3 changed files with 10 additions and 4 deletions

View File

@ -162,7 +162,11 @@ class DepositListItem {
// get tx with fewest confirmations // get tx with fewest confirmations
MoneroTxWallet highestTx = null; MoneroTxWallet highestTx = null;
for (MoneroTxWallet tx : txs) if (highestTx == null || tx.getNumConfirmations() < highestTx.getNumConfirmations()) highestTx = tx; for (MoneroTxWallet tx : txs) {
if (highestTx == null || tx.getHeight() == null || (highestTx.getHeight() != null && tx.getHeight() > highestTx.getHeight())) {
highestTx = tx;
}
}
return highestTx; return highestTx;
} }
} }

View File

@ -318,12 +318,14 @@ public class DepositView extends ActivatableView<VBox, Void> {
/////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////////////
private void updateList() { private void updateList() {
observableList.forEach(DepositListItem::cleanup);
observableList.clear();
// cache incoming txs // cache incoming txs
txsWithIncomingOutputs = xmrWalletService.getTxsWithIncomingOutputs(); txsWithIncomingOutputs = xmrWalletService.getTxsWithIncomingOutputs();
// clear existing items
observableList.forEach(DepositListItem::cleanup);
observableList.clear();
// add address entries // add address entries
xmrWalletService.getAddressEntries() xmrWalletService.getAddressEntries()
.forEach(e -> observableList.add(new DepositListItem(e, xmrWalletService, formatter, txsWithIncomingOutputs))); .forEach(e -> observableList.add(new DepositListItem(e, xmrWalletService, formatter, txsWithIncomingOutputs)));

View File

@ -528,7 +528,7 @@ public class GUIUtil {
public static void updateConfidence(MoneroTx tx, public static void updateConfidence(MoneroTx tx,
Tooltip tooltip, Tooltip tooltip,
TxConfidenceIndicator txConfidenceIndicator) { TxConfidenceIndicator txConfidenceIndicator) {
if (tx != null && !tx.isRelayed()) { if (tx != null && (tx.getNumConfirmations() == null || !tx.isRelayed())) {
tooltip.setText(Res.get("confidence.unknown")); tooltip.setText(Res.get("confidence.unknown"));
txConfidenceIndicator.setProgress(0); txConfidenceIndicator.setProgress(0);
} else if (tx != null && tx.isFailed()) { } else if (tx != null && tx.isFailed()) {