Fix regression with deleting tasks

This commit is contained in:
hunteraraujo
2023-09-16 17:28:58 -07:00
parent f76d45cd9e
commit 25ce1d6be0
3 changed files with 8 additions and 4 deletions

View File

@@ -65,6 +65,9 @@ void main() async {
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final taskService = Provider.of<TaskService>(context, listen: false);
taskService.loadDeletedTasks();
return MaterialApp( return MaterialApp(
title: 'AutoGPT Flutter Client', title: 'AutoGPT Flutter Client',
theme: ThemeData( theme: ThemeData(

View File

@@ -63,9 +63,10 @@ class TaskService {
} }
Future<void> loadDeletedTasks() async { Future<void> loadDeletedTasks() async {
_deletedTaskIds = SharedPreferences prefs = await SharedPreferences.getInstance();
(await SharedPreferences.getInstance()).getStringList('deletedTasks') ?? _deletedTaskIds = prefs.getStringList('deletedTasks') ?? [];
[];
// Print out all deleted task IDs
print("Deleted tasks fetched successfully!"); print("Deleted tasks fetched successfully!");
} }

View File

@@ -39,7 +39,7 @@ class TaskViewModel with ChangeNotifier {
_taskService.saveDeletedTask(taskId); _taskService.saveDeletedTask(taskId);
tasks.removeWhere((task) => task.id == taskId); tasks.removeWhere((task) => task.id == taskId);
notifyListeners(); notifyListeners();
print("Tasks deleted successfully!"); print("Task $taskId deleted successfully!");
} }
/// Fetches tasks from the data source. /// Fetches tasks from the data source.