Fixed bug where task list did not update when creating new task

This commit is contained in:
hunteraraujo
2023-09-27 20:27:21 -07:00
parent 37fbb52d19
commit c739e049c3
2 changed files with 5 additions and 5 deletions

View File

@@ -1,6 +1,5 @@
import 'dart:convert';
import 'package:auto_gpt_flutter_client/models/task.dart';
import 'package:auto_gpt_flutter_client/models/task_response.dart';
import 'package:auto_gpt_flutter_client/models/test_suite.dart';
import 'package:flutter/foundation.dart';
import 'package:collection/collection.dart';
@@ -34,9 +33,10 @@ class TaskViewModel with ChangeNotifier {
final newTaskObject =
Task(id: createdTask['task_id'], title: createdTask['input']);
// Update local tasks list and notify listeners
_tasks.add(newTaskObject);
notifyListeners();
fetchAndCombineData();
final taskId = newTaskObject.id;
print("Task $taskId created successfully!");
return newTaskObject.id; // Return the ID of the new task
}

View File

@@ -38,7 +38,7 @@ class _ChatViewState extends State<ChatView> {
}
});
// Schedule the fetchTasks call for after the initial build
// Schedule the fetchChatsForTask call for after the initial build
WidgetsBinding.instance.addPostFrameCallback((_) {
widget.viewModel.fetchChatsForTask();
});