mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-08-06 15:21:21 +08:00
NoteEditor Discard Changes: Do a git checkout
on the file
This way it will go back to the exact original version. Our Note loading and saving sometimes changes the yaml metadata order. Also, this allows us to autosave the note file.
This commit is contained in:
lib
@ -373,10 +373,9 @@ class NoteEditorState extends State<NoteEditor> {
|
||||
}
|
||||
}
|
||||
|
||||
void _discardChangesSelected(Note note) {
|
||||
if (_noteModified(note)) {
|
||||
note.data = originalNoteData;
|
||||
}
|
||||
void _discardChangesSelected(Note note) async {
|
||||
var stateContainer = Provider.of<StateContainer>(context, listen: false);
|
||||
stateContainer.discardChanges(note);
|
||||
|
||||
Navigator.pop(context);
|
||||
}
|
||||
|
@ -413,6 +413,12 @@ class StateContainer with ChangeNotifier {
|
||||
_loadNotes();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> discardChanges(Note note) async {
|
||||
var repo = await GitRepository.load(repoPath);
|
||||
await repo.checkout(note.filePath);
|
||||
return note.load();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _copyDirectory(String source, String destination) async {
|
||||
|
Reference in New Issue
Block a user