mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-02 04:47:01 +08:00
NoteEditing: Make sure we report exceptions on save
We don't want to silently ignore these.
This commit is contained in:
@ -10,6 +10,7 @@ import 'package:gitjournal/editors/journal_editor.dart';
|
||||
import 'package:gitjournal/editors/markdown_editor.dart';
|
||||
import 'package:gitjournal/editors/raw_editor.dart';
|
||||
import 'package:gitjournal/editors/checklist_editor.dart';
|
||||
import 'package:gitjournal/error_reporting.dart';
|
||||
import 'package:gitjournal/state_container.dart';
|
||||
import 'package:gitjournal/utils/logger.dart';
|
||||
import 'package:gitjournal/widgets/folder_selection_dialog.dart';
|
||||
@ -303,12 +304,18 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
return false;
|
||||
}
|
||||
|
||||
void _saveNote(Note note) {
|
||||
void _saveNote(Note note) async {
|
||||
if (!_noteModified(note)) return;
|
||||
|
||||
Log.d("Note modified - saving");
|
||||
var stateContainer = Provider.of<StateContainer>(context, listen: false);
|
||||
_isNewNote ? stateContainer.addNote(note) : stateContainer.updateNote(note);
|
||||
try {
|
||||
var stateContainer = Provider.of<StateContainer>(context, listen: false);
|
||||
_isNewNote
|
||||
? await stateContainer.addNote(note)
|
||||
: await stateContainer.updateNote(note);
|
||||
} catch (e, stackTrace) {
|
||||
logException(e, stackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
Note _getNoteFromEditor() {
|
||||
|
@ -256,7 +256,7 @@ class StateContainer with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
void addNote(Note note) async {
|
||||
Future<void> addNote(Note note) async {
|
||||
logEvent(Event.NoteAdded);
|
||||
|
||||
note.parent.add(note);
|
||||
@ -310,7 +310,7 @@ class StateContainer with ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
void updateNote(Note note) async {
|
||||
Future<void> updateNote(Note note) async {
|
||||
logEvent(Event.NoteUpdated);
|
||||
|
||||
note.updateModified();
|
||||
|
Reference in New Issue
Block a user