@@ -109,8 +109,34 @@ class NotesModel extends ChangeNotifier {
109
109
transcribed: true ,
110
110
transcript: text,
111
111
isCollapsed: false );
112
- notes.add (note);
113
- await _dbRepository.addNote (note);
112
+
113
+ if (currentlyExpanded != null && ! currentlyExpanded! .isComplete) {
114
+ note.parentNoteId = currentlyExpanded! .id;
115
+ currentlyExpanded! .insertAfter (note);
116
+ await _dbRepository.addNote (note);
117
+ // Due to notes below/nonstandard insertion point
118
+ await _dbRepository.realignNotes (notes);
119
+ Sentry .addBreadcrumb (Breadcrumb (
120
+ message: "Insert after expanded" , timestamp: DateTime .now ()));
121
+ } else {
122
+ notes.add (note);
123
+ await _dbRepository.addNote (note);
124
+ }
125
+ notifyListeners ();
126
+ if (shouldLocate) {
127
+ final loc = await locationInstance.getLocation ();
128
+ if (loc.latitude != null &&
129
+ loc.longitude != null &&
130
+ loc.accuracy != null &&
131
+ loc.accuracy! < 1000.0 ) {
132
+ note.longitude = loc.longitude;
133
+ note.latitude = loc.latitude;
134
+ await _dbRepository.updateNote (note);
135
+ } else {
136
+ Sentry .addBreadcrumb (Breadcrumb (
137
+ message: "Couldn't locate note" , timestamp: DateTime .now ()));
138
+ }
139
+ }
114
140
notifyListeners ();
115
141
}
116
142
@@ -424,6 +450,7 @@ class NotesModel extends ChangeNotifier {
424
450
}
425
451
});
426
452
await _dbRepository.realignNotes (notes);
453
+ currentlyExpanded = null ;
427
454
Sentry .addBreadcrumb (
428
455
Breadcrumb (message: "Reordered note" , timestamp: DateTime .now ()));
429
456
assert (notes.length == initialSize);
0 commit comments