feat: Implement permanent deletion and restoration of notes with updated UI
This commit is contained in:
@@ -111,6 +111,18 @@ class AppDatabase extends _$AppDatabase {
|
||||
return deleteNote(id, removedIndex);
|
||||
}
|
||||
|
||||
Future<void> permanentlyDeleteNote(int id) async {
|
||||
await (update(notes)..where((n) => n.id.equals(id))).write(
|
||||
NotesCompanion(
|
||||
title: const Value(''),
|
||||
body: const Value(''),
|
||||
categoryId: const Value(null),
|
||||
isDeleted: const Value(true),
|
||||
updatedAt: Value(DateTime.now()),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> moveNote({
|
||||
required int id,
|
||||
required int oldIndex,
|
||||
@@ -146,6 +158,12 @@ class AppDatabase extends _$AppDatabase {
|
||||
)..where((n) => n.updatedAt.isBiggerThanValue(since))).get();
|
||||
}
|
||||
|
||||
Future<List<DbNote>> getDeletedNotes() {
|
||||
return (select(notes)
|
||||
..where((n) => n.isDeleted.equals(true) & n.title.isNotValue('') & n.body.isNotValue('')))
|
||||
.get();
|
||||
}
|
||||
|
||||
Future<List<DbCategory>> getCategoriesChangedSince(DateTime since) {
|
||||
return (select(
|
||||
categories,
|
||||
|
||||
Reference in New Issue
Block a user