mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 14:34:23 +01:00
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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user