refactor: Update Note and Category models to use 'id' instead of 'uuid', and adjust related database operations
- Changed 'uuid' to 'id' in Note and Category models for consistency. - Updated database operations in NoteRepository to reflect the new 'id' field. - Modified sync models to accommodate changes in Note and Category structures. - Adjusted the handling of notes and categories during synchronization. - Refactored the note editor and home screen to use the new 'id' field. - Ensured that the 'isDirty' flag is properly set and utilized across models.
This commit is contained in:
@@ -154,9 +154,9 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
// Don't let DB errors cause the app to reset the vault automatically.
|
||||
debugPrint('Failed to move note: $e\n$st');
|
||||
if (!mounted) return;
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text('Error al reordenar la nota: $e')),
|
||||
);
|
||||
ScaffoldMessenger.of(
|
||||
context,
|
||||
).showSnackBar(SnackBar(content: Text('Error al reordenar la nota: $e')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,9 +385,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: NoteCard(
|
||||
key: ValueKey<int>(
|
||||
filteredNotes[index].id ??
|
||||
filteredNotes[index].index,
|
||||
key: ValueKey<String>(
|
||||
filteredNotes[index].id,
|
||||
),
|
||||
note: filteredNotes[index],
|
||||
onTap: () =>
|
||||
@@ -510,9 +509,8 @@ class _HomeScreenState extends State<HomeScreen> {
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: NoteCard(
|
||||
key: ValueKey<int>(
|
||||
filteredNotes[index].id ??
|
||||
filteredNotes[index].index,
|
||||
key: ValueKey<String>(
|
||||
filteredNotes[index].id,
|
||||
),
|
||||
note: filteredNotes[index],
|
||||
onTap: () =>
|
||||
|
||||
@@ -89,7 +89,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_isNewNote = widget.note?.id == null;
|
||||
_isNewNote = widget.note == null;
|
||||
|
||||
if (_isNewNote) {
|
||||
final DateTime now = DateTime.now();
|
||||
@@ -98,7 +98,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
body: '',
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
index: 0,
|
||||
position: 0,
|
||||
);
|
||||
} else {
|
||||
_currentNote = widget.note!;
|
||||
@@ -143,6 +143,7 @@ class _NoteEditorScreenState extends State<NoteEditorScreen> {
|
||||
title: title.isEmpty ? 'Sin título' : title,
|
||||
body: body,
|
||||
updatedAt: DateTime.now(),
|
||||
isDirty: true,
|
||||
);
|
||||
|
||||
_complete(updatedNote);
|
||||
|
||||
Reference in New Issue
Block a user