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