feat: add todo cache repository and precise invalidation
This commit is contained in:
@@ -16,6 +16,7 @@ import '../../../../shared/widgets/toast/toast_type.dart';
|
||||
import '../../../calendar/ui/calendar_state_manager.dart';
|
||||
import '../../../calendar/ui/widgets/bottom_dock.dart';
|
||||
import '../../data/todo_api.dart';
|
||||
import '../../data/todo_repository.dart';
|
||||
|
||||
class TodoQuadrantsScreen extends StatefulWidget {
|
||||
const TodoQuadrantsScreen({super.key});
|
||||
@@ -26,6 +27,7 @@ class TodoQuadrantsScreen extends StatefulWidget {
|
||||
|
||||
class _TodoQuadrantsScreenState extends State<TodoQuadrantsScreen> {
|
||||
final TodoApi _todoApi = sl<TodoApi>();
|
||||
final TodoRepository _todoRepository = sl<TodoRepository>();
|
||||
|
||||
List<TodoResponse> _todos = [];
|
||||
bool _isLoading = true;
|
||||
@@ -210,7 +212,9 @@ class _TodoQuadrantsScreenState extends State<TodoQuadrantsScreen> {
|
||||
});
|
||||
|
||||
try {
|
||||
final todos = await _todoApi.getTodos(status: 'pending');
|
||||
final todos = await _todoRepository.getPendingTodos(
|
||||
forceRefresh: !showPageLoader,
|
||||
);
|
||||
if (!mounted) {
|
||||
return;
|
||||
}
|
||||
@@ -263,7 +267,7 @@ class _TodoQuadrantsScreenState extends State<TodoQuadrantsScreen> {
|
||||
|
||||
Future<void> _completeTodo(TodoResponse todo) async {
|
||||
try {
|
||||
await _todoApi.completeTodo(todo.id);
|
||||
await _todoRepository.completeTodo(todo.id);
|
||||
if (mounted) {
|
||||
Toast.show(context, '已完成', type: ToastType.success);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user