From c739e049c3e4b70332cbc7e7238f6ebcdba5967e Mon Sep 17 00:00:00 2001 From: hunteraraujo Date: Wed, 27 Sep 2023 20:27:21 -0700 Subject: [PATCH] Fixed bug where task list did not update when creating new task --- frontend/lib/viewmodels/task_viewmodel.dart | 8 ++++---- frontend/lib/views/chat/chat_view.dart | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/lib/viewmodels/task_viewmodel.dart b/frontend/lib/viewmodels/task_viewmodel.dart index d00934f1..7b0bbc72 100644 --- a/frontend/lib/viewmodels/task_viewmodel.dart +++ b/frontend/lib/viewmodels/task_viewmodel.dart @@ -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 } diff --git a/frontend/lib/views/chat/chat_view.dart b/frontend/lib/views/chat/chat_view.dart index 34517d0b..a03cb682 100644 --- a/frontend/lib/views/chat/chat_view.dart +++ b/frontend/lib/views/chat/chat_view.dart @@ -38,7 +38,7 @@ class _ChatViewState extends State { } }); - // Schedule the fetchTasks call for after the initial build + // Schedule the fetchChatsForTask call for after the initial build WidgetsBinding.instance.addPostFrameCallback((_) { widget.viewModel.fetchChatsForTask(); });