Skip to content

Commit

Permalink
load notes on refresh (#783)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2049r authored Sep 8, 2021
1 parent b576a9d commit 84ec1ef
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/src/main/java/com/m2049r/xmrwallet/WalletFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,14 @@ public void onRefreshed(final Wallet wallet, boolean full) {
Timber.d("onRefreshed(%b)", full);

if (adapter.needsTransactionUpdateOnNewBlock()) {
wallet.getHistory().refresh();
wallet.refreshHistory();
full = true;
}
if (full) {
List<TransactionInfo> list = new ArrayList<>();
final long streetHeight = activityCallback.getStreetModeHeight();
Timber.d("StreetHeight=%d", streetHeight);
wallet.getHistory().refresh();
wallet.refreshHistory();
for (TransactionInfo info : wallet.getHistory().getAll()) {
Timber.d("TxHeight=%d, Label=%s", info.blockheight, info.subaddressLabel);
if ((info.isPending || (info.blockheight >= streetHeight))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
return (oldItem.direction == newItem.direction)
&& (oldItem.isPending == newItem.isPending)
&& (oldItem.isFailed == newItem.isFailed)
&& (oldItem.confirmations == newItem.confirmations)
&& ((oldItem.confirmations == newItem.confirmations) || (oldItem.isConfirmed()))
&& (oldItem.subaddressLabel.equals(newItem.subaddressLabel))
&& (Objects.equals(oldItem.notes, newItem.notes));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public TransactionHistory(long handle, int accountIndex) {
this.accountIndex = accountIndex;
}

public void loadNotes(Wallet wallet) {
private void loadNotes(Wallet wallet) {
for (TransactionInfo info : transactions) {
info.notes = wallet.getUserNote(info.hash);
}
Expand All @@ -61,30 +61,22 @@ public List<TransactionInfo> getAll() {

private List<TransactionInfo> transactions = new ArrayList<>();

public void refreshWithNotes(Wallet wallet) {
void refreshWithNotes(Wallet wallet) {
refresh();
loadNotes(wallet);
}

// public void refresh() {
// transactions = refreshJ();
// }

public void refresh() {
private void refresh() {
List<TransactionInfo> transactionInfos = refreshJ();
Timber.d("refreshed %d", transactionInfos.size());
Timber.d("refresh size=%d", transactionInfos.size());
for (Iterator<TransactionInfo> iterator = transactionInfos.iterator(); iterator.hasNext(); ) {
TransactionInfo info = iterator.next();
if (info.accountIndex != accountIndex) {
iterator.remove();
Timber.d("removed %s", info.hash);
} else {
Timber.d("kept %s", info.hash);
}
}
transactions = transactionInfos;
}

private native List<TransactionInfo> refreshJ();

}
6 changes: 5 additions & 1 deletion app/src/main/java/com/m2049r/xmrwallet/model/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,10 @@ public TransactionHistory getHistory() {

private native long getHistoryJ();

public void refreshHistory() {
getHistory().refreshWithNotes(this);
}

//virtual AddressBook * addressBook() const = 0;
//virtual void setListener(WalletListener *) = 0;

Expand Down Expand Up @@ -462,7 +466,7 @@ public void setAccountLabel(int accountIndex, String label) {

public void setSubaddressLabel(int addressIndex, String label) {
setSubaddressLabel(accountIndex, addressIndex, label);
getHistory().refreshWithNotes(this);
refreshHistory();
}

public native void setSubaddressLabel(int accountIndex, int addressIndex, String label);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void newBlock(long height) {
if (!wallet.isSynchronized()) {
updated = true;
// we want to see our transactions as they come in
wallet.getHistory().refresh();
wallet.refreshHistory();
int txCount = wallet.getHistory().getCount();
if (txCount > lastTxCount) {
// update the transaction list only if we have more than before
Expand Down Expand Up @@ -152,7 +152,7 @@ public void refreshed() { // this means it's synced
wallet.setSynchronized();
if (updated) {
updateDaemonState(wallet, wallet.getBlockChainHeight());
wallet.getHistory().refreshWithNotes(wallet);
wallet.refreshHistory();
if (observer != null) {
updated = !observer.onRefreshed(wallet, true);
}
Expand Down

0 comments on commit 84ec1ef

Please sign in to comment.