feat: Update category deletion logic to reset related notes and track changes

This commit is contained in:
2026-05-21 12:01:44 +02:00
parent 5412d31066
commit 95c3e6fc38
3 changed files with 11 additions and 1 deletions
+5 -1
View File
@@ -86,7 +86,11 @@ class AppDatabase extends _$AppDatabase {
Future<void> deleteCategory(String id) { Future<void> deleteCategory(String id) {
return (update(categories)..where((c) => c.id.equals(id))).write( return (update(categories)..where((c) => c.id.equals(id))).write(
CategoriesCompanion(isDeleted: Value(true)), CategoriesCompanion(
isDeleted: const Value(true),
updatedAt: Value(DateTime.now()),
isDirty: const Value(true),
),
); );
} }
+5
View File
@@ -87,6 +87,11 @@ class NoteRepository {
Future<void> deleteCategory(String id) async { Future<void> deleteCategory(String id) async {
await _database.deleteCategory(id); await _database.deleteCategory(id);
await _database.customStatement(
'UPDATE notes SET category_id = NULL, is_dirty = 1 WHERE category_id = ?',
[id],
);
} }
Future<Note> createNote(Note note) async { Future<Note> createNote(Note note) async {
+1
View File
@@ -258,6 +258,7 @@ class SyncCategoryResponse {
colorValue: colorValue, colorValue: colorValue,
iconCodePoint: iconCodePoint, iconCodePoint: iconCodePoint,
updatedAt: updatedAt, updatedAt: updatedAt,
isDirty: false,
); );
} }
} }