mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 12:23:44 +08:00
Ensure new notes always have a proper file ending
This commit is contained in:
@ -70,22 +70,24 @@ class Note with NotesNotifier {
|
||||
Note.newNote(this.parent) {
|
||||
created = DateTime.now();
|
||||
_loadState = NoteLoadState.Loaded;
|
||||
_fileFormat = NoteFileFormat.Markdown;
|
||||
}
|
||||
|
||||
String get filePath {
|
||||
if (_filePath == null) {
|
||||
_filePath = p.join(parent.folderPath, _buildFileName());
|
||||
switch (_fileFormat) {
|
||||
case NoteFileFormat.Markdown:
|
||||
if (!_filePath.toLowerCase().endsWith('.md')) {
|
||||
_filePath += '.md';
|
||||
}
|
||||
break;
|
||||
case NoteFileFormat.Txt:
|
||||
if (!_filePath.toLowerCase().endsWith('.txt')) {
|
||||
_filePath += '.txt';
|
||||
}
|
||||
break;
|
||||
case NoteFileFormat.Markdown:
|
||||
default:
|
||||
if (!_filePath.toLowerCase().endsWith('.md')) {
|
||||
_filePath += '.md';
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user