Implement full pagination support for task fetching

Refactored the TaskService and TaskViewModel classes to fully support paginated fetching of tasks. The solution fetches tasks page by page until all tasks have been retrieved, accommodating the API's pagination mechanism. Renamed `listAllTasks` to `fetchTasksPage` to better reflect its purpose and introduced a new method, `fetchAllTasks`, to handle the paginated fetching logic.
This commit is contained in:
hunteraraujo
2023-09-27 00:11:24 -07:00
parent 5df70eabd8
commit dc4ca47bc7
2 changed files with 26 additions and 7 deletions

View File

@@ -52,8 +52,7 @@ class TaskViewModel with ChangeNotifier {
/// Fetches tasks from the data source.
Future<void> fetchTasks() async {
try {
final TaskResponse tasksResponse = await _taskService.listAllTasks();
final tasksFromApi = tasksResponse.tasks;
final tasksFromApi = await _taskService.fetchAllTasks();
_tasks = tasksFromApi
.where((task) => !_taskService.isTaskDeleted(task.id))
.toList();