Skip to content

Commit

Permalink
Merge pull request #402 from kumulynja/check-current-send-pj-on-failure
Browse files Browse the repository at this point in the history
fix: only show error for current send pj session
  • Loading branch information
i5hi authored Dec 27, 2024
2 parents a118d9a + 526a79f commit afdd073
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions lib/_pkg/payjoin/event.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ class PayjoinSenderPostMessageASuccessEvent extends PayjoinEvent {
PayjoinSenderPostMessageASuccessEvent({required this.pjUri});
}

class PayjoinFailureEvent extends PayjoinEvent {
class PayjoinSendFailureEvent extends PayjoinEvent {
final String pjUri;
final Object? error;
PayjoinFailureEvent({this.error});
PayjoinSendFailureEvent({required this.pjUri, this.error});
}

class PayjoinEventListener extends StatefulWidget {
Expand Down
2 changes: 1 addition & 1 deletion lib/_pkg/payjoin/manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class PayjoinManager {
}
} else if (message is Err) {
PayjoinEventBus().emit(
PayjoinFailureEvent(error: message),
PayjoinSendFailureEvent(pjUri: pjUri, error: message),
);
await _cleanupSession(pjUri);
completer.complete(message);
Expand Down
3 changes: 2 additions & 1 deletion lib/send/bloc/send_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ class SendCubit extends Cubit<SendState> {
);
} else if (event is PayjoinBroadcastEvent) {
state.selectedWalletBloc!.add(SyncWallet());
} else if (event is PayjoinFailureEvent) {
} else if (event is PayjoinSendFailureEvent &&
event.pjUri == state.payjoinEndpoint.toString()) {
emit(
state.copyWith(
errSending: event.error.toString(),
Expand Down

0 comments on commit afdd073

Please sign in to comment.