Skip to content

Commit 3a0a3f5

Browse files
committed
Add parent and location relations to text notes
1 parent e116b33 commit 3a0a3f5

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

lib/state/notes_state.dart

+29-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,34 @@ class NotesModel extends ChangeNotifier {
109109
transcribed: true,
110110
transcript: text,
111111
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+
}
114140
notifyListeners();
115141
}
116142

@@ -424,6 +450,7 @@ class NotesModel extends ChangeNotifier {
424450
}
425451
});
426452
await _dbRepository.realignNotes(notes);
453+
currentlyExpanded = null;
427454
Sentry.addBreadcrumb(
428455
Breadcrumb(message: "Reordered note", timestamp: DateTime.now()));
429456
assert(notes.length == initialSize);

lib/views/notes_view.dart

+1-3
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,7 @@ class _NotesViewState extends State<_NotesView> {
8383
_textController.clear();
8484
Future<void> _onSubmitted(BuildContext ctx) async {
8585
if (_textController.value.text.isNotEmpty) {
86-
await context
87-
.read<NotesModel>()
88-
.createTextNote(_textController.value.text);
86+
context.read<NotesModel>().createTextNote(_textController.value.text);
8987
Navigator.of(ctx, rootNavigator: true).pop();
9088
} else {
9189
ScaffoldMessenger.of(ctx)

pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
1515
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
1616
# Read more about iOS versioning at
1717
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18-
version: 1.22.4+93
18+
version: 1.23.0+94
1919

2020
environment:
2121
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)