mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-07-01 20:43:20 +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) {
|
Note.newNote(this.parent) {
|
||||||
created = DateTime.now();
|
created = DateTime.now();
|
||||||
_loadState = NoteLoadState.Loaded;
|
_loadState = NoteLoadState.Loaded;
|
||||||
|
_fileFormat = NoteFileFormat.Markdown;
|
||||||
}
|
}
|
||||||
|
|
||||||
String get filePath {
|
String get filePath {
|
||||||
if (_filePath == null) {
|
if (_filePath == null) {
|
||||||
_filePath = p.join(parent.folderPath, _buildFileName());
|
_filePath = p.join(parent.folderPath, _buildFileName());
|
||||||
switch (_fileFormat) {
|
switch (_fileFormat) {
|
||||||
case NoteFileFormat.Markdown:
|
|
||||||
if (!_filePath.toLowerCase().endsWith('.md')) {
|
|
||||||
_filePath += '.md';
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case NoteFileFormat.Txt:
|
case NoteFileFormat.Txt:
|
||||||
if (!_filePath.toLowerCase().endsWith('.txt')) {
|
if (!_filePath.toLowerCase().endsWith('.txt')) {
|
||||||
_filePath += '.txt';
|
_filePath += '.txt';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case NoteFileFormat.Markdown:
|
||||||
|
default:
|
||||||
|
if (!_filePath.toLowerCase().endsWith('.md')) {
|
||||||
|
_filePath += '.md';
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user