feat: Update category deletion logic to reset related notes and track changes
This commit is contained in:
@@ -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),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -258,6 +258,7 @@ class SyncCategoryResponse {
|
|||||||
colorValue: colorValue,
|
colorValue: colorValue,
|
||||||
iconCodePoint: iconCodePoint,
|
iconCodePoint: iconCodePoint,
|
||||||
updatedAt: updatedAt,
|
updatedAt: updatedAt,
|
||||||
|
isDirty: false,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user