Fix disappearing recipientAddress for XMR Transactions (#1784)

Konstantin Ullrich committed Oct 30, 2024 at 17:57 UTC 198510533e854f437037573fe0575d73a9b21971
1 file changed +11 -16
lib/view_model/transaction_details_view_model.dart
+11 -16
@@ -83,18 +83,19 @@ abstract class TransactionDetailsViewModelBase with Store {
83 break;
84 }
85
86 + final descriptionKey =
87 + '${transactionInfo.txHash}_${wallet.walletAddresses.primaryAddress}';
88 + final description = transactionDescriptionBox.values.firstWhere(
89 + (val) => val.id == descriptionKey || val.id == transactionInfo.txHash,
90 + orElse: () => TransactionDescription(id: descriptionKey));
91 +
92 if (showRecipientAddress && !isRecipientAddressShown) {
87 - try {
88 - final recipientAddress = transactionDescriptionBox.values
89 - .firstWhere((val) => val.id == transactionInfo.txHash)
90 - .recipientAddress;
93 + final recipientAddress = description.recipientAddress;
94
92 - if (recipientAddress?.isNotEmpty ?? false) {
93 - items.add(StandartListItem(
94 - title: S.current.transaction_details_recipient_address, value: recipientAddress!));
95 - }
96 - } catch (_) {
97 - // FIX-ME: Unhandled exception
95 + if (recipientAddress?.isNotEmpty ?? false) {
96 + items.add(StandartListItem(
97 + title: S.current.transaction_details_recipient_address,
98 + value: recipientAddress!));
99 }
100 }
101
@@ -110,12 +111,6 @@ abstract class TransactionDetailsViewModelBase with Store {
111 } catch (e) {}
112 }));
113
113 - final descriptionKey = '${transactionInfo.txHash}_${wallet.walletAddresses.primaryAddress}';
114 -
115 - final description = transactionDescriptionBox.values.firstWhere(
116 - (val) => val.id == descriptionKey || val.id == transactionInfo.txHash,
117 - orElse: () => TransactionDescription(id: descriptionKey));
118 -
114 items.add(TextFieldListItem(
115 title: S.current.note_tap_to_change,
116 value: description.note,