Skip to content

Commit

Permalink
Merge pull request #632 from breez/ubbabeck-paymentstatus
Browse files Browse the repository at this point in the history
apply payment status
  • Loading branch information
ubbabeck authored Sep 25, 2023
2 parents 8b07abf + 12c97ca commit f3ba7ce
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 13 deletions.
5 changes: 3 additions & 2 deletions lib/background/payment_hash_poller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class PaymentHashPoller {
);
for (var payment in paymentList) {
final detailsData = payment.details.data;
final isPaymentReceived =
payment.status != PaymentStatus.Pending && detailsData is LnPaymentDetails && detailsData.paymentHash == paymentHash;
final isPaymentReceived = payment.status == PaymentStatus.Complete &&
detailsData is LnPaymentDetails &&
detailsData.paymentHash == paymentHash;
if (isPaymentReceived) {
print("Payment received! Stop polling.");
timer.cancel();
Expand Down
6 changes: 3 additions & 3 deletions lib/models/payment_minutiae.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentMinutiae {
final int amountSat;
final bool hasMetadata;
final bool isKeySend;
final bool isPending;
final PaymentStatus status;

const PaymentMinutiae({
required this.id,
Expand All @@ -49,7 +49,7 @@ class PaymentMinutiae {
required this.amountSat,
required this.hasMetadata,
required this.isKeySend,
required this.isPending,
required this.status,
});

factory PaymentMinutiae.fromPayment(Payment payment, BreezTranslations texts) {
Expand All @@ -72,7 +72,7 @@ class PaymentMinutiae {
amountSat: factory._amountSat(),
hasMetadata: factory._hasMetadata(),
isKeySend: factory._isKeySend(),
isPending: payment.status == PaymentStatus.Pending,
status: payment.status,
);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:breez_sdk/bridge_generated.dart';
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/models/payment_minutiae.dart';
import 'package:c_breez/routes/home/widgets/payments_list/dialog/tx_widget.dart';
Expand All @@ -16,7 +17,7 @@ class ClosedChannelPaymentDetailsWidget extends StatelessWidget {
final themeData = Theme.of(context);
final texts = context.texts();

if (!paymentMinutiae.isPending) {
if (paymentMinutiae.status == PaymentStatus.Complete) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:breez_sdk/bridge_generated.dart';
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/models/payment_minutiae.dart';
import 'package:c_breez/routes/home/widgets/payments_list/dialog/closed_channel_payment_details.dart';
Expand All @@ -19,7 +20,7 @@ class PaymentDetailsDialogClosedChannelDialog extends StatelessWidget {
return AlertDialog(
titlePadding: const EdgeInsets.fromLTRB(24, 22, 0, 16),
title: Text(
paymentMinutiae.isPending
paymentMinutiae.status == PaymentStatus.Pending
? texts.payment_details_dialog_closed_channel_title_pending
: texts.payment_details_dialog_closed_channel_title,
style: themeData.dialogTheme.titleTextStyle,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:breez_sdk/bridge_generated.dart';
import 'package:breez_translations/breez_translations_locales.dart';
import 'package:c_breez/models/payment_minutiae.dart';
import 'package:flutter/material.dart';
Expand All @@ -18,7 +19,7 @@ class PaymentDetailsDialogExpiration extends StatelessWidget {
final texts = context.texts();
final themeData = Theme.of(context);

if (!paymentMinutiae.isPending) {
if (paymentMinutiae.status == PaymentStatus.Complete) {
return Container();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ class PaymentItemAmount extends StatelessWidget {
);

return Column(
mainAxisAlignment: _paymentMinutiae.feeMilliSat == 0 || _paymentMinutiae.isPending
? MainAxisAlignment.center
: MainAxisAlignment.spaceAround,
mainAxisAlignment:
_paymentMinutiae.feeMilliSat == 0 || _paymentMinutiae.status == PaymentStatus.Pending
? MainAxisAlignment.center
: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
Expand All @@ -59,7 +60,7 @@ class PaymentItemAmount extends StatelessWidget {
: texts.wallet_dashboard_payment_item_balance_negative(amount),
style: themeData.paymentItemAmountTextStyle,
),
(fee == 0 || _paymentMinutiae.isPending)
(fee == 0 || _paymentMinutiae.status == PaymentStatus.Pending)
? const SizedBox()
: Text(
hideBalance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class PaymentItemSubtitle extends StatelessWidget {
BreezDateUtils.formatTimelineRelative(_paymentMinutiae.paymentTime),
style: subtitleTextStyle,
),
_paymentMinutiae.isPending
_paymentMinutiae.status == PaymentStatus.Pending
? Text(
texts.wallet_dashboard_payment_item_balance_pending_suffix,
style: subtitleTextStyle.copyWith(
Expand Down

0 comments on commit f3ba7ce

Please sign in to comment.