Add pagination to recurring invoices
This commit is contained in:
parent
e16ff984d8
commit
2260272845
|
|
@ -33,8 +33,9 @@ class RecurringInvoiceRepository {
|
|||
}
|
||||
|
||||
Future<BuiltList<InvoiceEntity>> loadList(
|
||||
Credentials credentials, bool filterDeleted) async {
|
||||
String url = credentials.url + '/recurring_invoices?';
|
||||
Credentials credentials, int page, bool filterDeleted) async {
|
||||
String url = credentials.url +
|
||||
'/recurring_invoices?per_page=$kMaxRecordsPerPage&page=$page';
|
||||
|
||||
if (filterDeleted) {
|
||||
url += '&filter_deleted_clients=true';
|
||||
|
|
|
|||
|
|
@ -106,9 +106,10 @@ class LoadRecurringInvoiceActivity {
|
|||
}
|
||||
|
||||
class LoadRecurringInvoices {
|
||||
LoadRecurringInvoices({this.completer});
|
||||
LoadRecurringInvoices({this.completer, this.page = 1});
|
||||
|
||||
final Completer completer;
|
||||
final int page;
|
||||
}
|
||||
|
||||
class LoadRecurringInvoiceRequest implements StartLoading {}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// Flutter imports:
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:invoiceninja_flutter/constants.dart';
|
||||
import 'package:invoiceninja_flutter/redux/payment/payment_actions.dart';
|
||||
|
||||
// Package imports:
|
||||
|
|
@ -405,14 +406,23 @@ Middleware<AppState> _loadRecurringInvoices(
|
|||
repository
|
||||
.loadList(
|
||||
state.credentials,
|
||||
action.page,
|
||||
state.filterDeletedClients,
|
||||
)
|
||||
.then((data) {
|
||||
store.dispatch(LoadRecurringInvoicesSuccess(data));
|
||||
|
||||
if (data.length == kMaxRecordsPerPage) {
|
||||
store.dispatch(LoadRecurringInvoices(
|
||||
completer: action.completer,
|
||||
page: action.page + 1,
|
||||
));
|
||||
} else {
|
||||
if (action.completer != null) {
|
||||
action.completer.complete(null);
|
||||
}
|
||||
store.dispatch(LoadPayments());
|
||||
}
|
||||
}).catchError((Object error) {
|
||||
print(error);
|
||||
store.dispatch(LoadRecurringInvoicesFailure(error));
|
||||
|
|
|
|||
Loading…
Reference in New Issue