Skip to content

Commit

Permalink
fix(transaction-history-bloc): add event for onDone handler
Browse files Browse the repository at this point in the history
Empty transaction histories appear to step directly into the onDone handler, skipping the listener handler entirely. Adding this event shows the "No transaction history" message when there is no transaction history present for the coin
  • Loading branch information
takenagain committed Feb 11, 2025
1 parent 32a5594 commit 47fdc21
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/bloc/transaction_history/transaction_history_bloc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ class TransactionHistoryBloc

try {
add(const TransactionHistoryStartedLoading());
final asset = getSdkAsset(_sdk, event.coin.abbr);
final asset = _sdk.assets.available[event.coin.id];
if (asset == null) {
throw Exception('Asset ${event.coin.id} not found in known coins list');
}

// Subscribe to historical transactions
_historySubscription =
Expand Down Expand Up @@ -98,11 +101,18 @@ class TransactionHistoryBloc
);
},
onDone: () {
add(TransactionHistoryUpdated(transactions: state.transactions));
// Once historical load is complete, start watching for new transactions
_subscribeToNewTransactions(asset, event.coin);
},
);
} catch (e) {
} catch (e, s) {
log(
'Error loading transaction history: $e',
isError: true,
path: 'transaction_history_bloc->_onSubscribe',
trace: s,
);
add(
TransactionHistoryFailure(
error: TextError(error: LocaleKeys.somethingWrong.tr()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ final class TransactionHistoryState extends Equatable {
final BaseError? error;

@override
List<Object?> get props => [transactions, loading];
List<Object?> get props => [transactions, loading, error];

const TransactionHistoryState.initial()
: transactions = const [],
Expand Down

0 comments on commit 47fdc21

Please sign in to comment.