Skip to content

Commit f47f1a5

Browse files
committed
payments pending: show the next one if there are more than 1 - was showing a later payment if 2 or more were there
1 parent f73e073 commit f47f1a5

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

app/lib/actions/actions.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -551,11 +551,19 @@ Future pendingPayments(BuildContext context) async {
551551
paymentsTyped = await actions.paymentsJSONToPaymentsDataType(
552552
(getPaymentsOutput.jsonBody ?? ''),
553553
);
554-
FFAppState().pendingPayments = paymentsTyped
554+
final pendingPayments = paymentsTyped
555555
.where((e) => e.status == 'pending')
556556
.toList()
557-
.toList()
558-
.cast<PaymentStruct>();
557+
.cast<PaymentStruct>()
558+
.where((e) => e.scheduledAt != null)
559+
.toList();
560+
561+
if (pendingPayments.isEmpty) {
562+
FFAppState().pendingPayments = [];
563+
} else {
564+
pendingPayments.sort((a, b) => a.scheduledAt!.compareTo(b.scheduledAt!));
565+
FFAppState().pendingPayments = [pendingPayments.first];
566+
}
559567
return;
560568
} else {
561569
await action_blocks.handleMyEnergyApiCallFailure(

0 commit comments

Comments
 (0)