Re-implemented getting tasks with the new seperate endpoint #39
|
@ -71,7 +71,9 @@ class Client {
|
|||
throw new ApiException(
|
||||
response.statusCode, response.request.url.toString());
|
||||
}
|
||||
_maxPages = response.headers["x-pagination-total-pages"] != null ? int.parse(response.headers["x-pagination-total-pages"]) : 0;
|
||||
_maxPages = response.headers["x-pagination-total-pages"] != null
|
||||
? int.parse(response.headers["x-pagination-total-pages"])
|
||||
: 0;
|
||||
return _decoder.convert(response.body);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,9 +63,13 @@ class _ListPageState extends State<ListPage> {
|
|||
final index = i ~/ 2;
|
||||
|
||||
// This handles the case if there are no more elements in the list left which can be provided by the api
|
||||
if(VikunjaGlobal.of(context).taskService.maxPages == _currentPage && index == _tasks.length - 1) return null;
|
||||
if (VikunjaGlobal.of(context).taskService.maxPages ==
|
||||
_currentPage &&
|
||||
index == _tasks.length - 1) return null;
|
||||
|
||||
if (index >= _tasks.length && VikunjaGlobal.of(context).taskService.maxPages < _currentPage) {
|
||||
if (index >= _tasks.length &&
|
||||
VikunjaGlobal.of(context).taskService.maxPages <
|
||||
_currentPage) {
|
||||
_currentPage++;
|
||||
// FIXME: This does not get loaded until some time after the next (_tasks.length + 1) entry should have been rendered
|
||||
// This leads to errors because the render method tries to access an entry of _tasks with an index which does not exist
|
||||
|
@ -118,8 +122,11 @@ class _ListPageState extends State<ListPage> {
|
|||
}
|
||||
|
||||
Future<void> _loadTasksForPage(int page) {
|
||||
return VikunjaGlobal.of(context).taskService.getAll(
|
||||
_list.id, {"sort_by": "done", "order_by": "asc", "page": page.toString()}).then((tasks) {
|
||||
return VikunjaGlobal.of(context).taskService.getAll(_list.id, {
|
||||
"sort_by": "done",
|
||||
"order_by": "asc",
|
||||
"page": page.toString()
|
||||
}).then((tasks) {
|
||||
setState(() {
|
||||
_loading = false;
|
||||
_tasks.addAll(tasks);
|
||||
|
|
Reference in New Issue