diff --git a/assets/langs/en.yaml b/assets/langs/en.yaml index bc028bb9..337bf43e 100644 --- a/assets/langs/en.yaml +++ b/assets/langs/en.yaml @@ -268,7 +268,7 @@ widgets: rootFolder: Root Folder ignoredFiles: dot: Starts with a . - ext: Doesn't end with .md or .txt + ext: Doesn't end with one of the following - drawer: setup: Setup Git Host pro: Unlock Pro Version diff --git a/lib/core/note.dart b/lib/core/note.dart index e7bbcab3..20d84ac2 100644 --- a/lib/core/note.dart +++ b/lib/core/note.dart @@ -36,6 +36,34 @@ enum NoteType { Journal, } +class NoteFileFormatInfo { + static List allowedExtensions() { + return [ + '.md', + '.txt', + ]; + } + + static String defaultExtension(NoteFileFormat format) { + switch (format) { + case NoteFileFormat.Markdown: + return ".md"; + case NoteFileFormat.Txt: + return ".txt"; + default: + return ".md"; + } + } + + static bool isAllowedFileName(String filePath) { + var noteFilePath = filePath.toLowerCase(); + var isMarkdownFile = noteFilePath.endsWith('.md'); + var isTxtFile = noteFilePath.endsWith('.txt'); + + return isMarkdownFile || isTxtFile; + } +} + enum NoteFileFormat { Markdown, Txt, diff --git a/lib/core/notes_folder_fs.dart b/lib/core/notes_folder_fs.dart index 3bff203d..1cd8e7d6 100644 --- a/lib/core/notes_folder_fs.dart +++ b/lib/core/notes_folder_fs.dart @@ -250,13 +250,12 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder { }); continue; } - var noteFilePath = note.filePath.toLowerCase(); - var isMarkdownFile = noteFilePath.endsWith('.md'); - var isTxtFile = noteFilePath.endsWith('.txt'); - if (!isMarkdownFile && !isTxtFile) { + if (!NoteFileFormatInfo.isAllowedFileName(note.filePath)) { var ignoredFile = IgnoredFile( filePath: fsEntity.path, - reason: tr("ignoredFiles.ext"), + reason: tr("ignoredFiles.ext") + + " " + + NoteFileFormatInfo.allowedExtensions().join(' '), ); _ignoredFiles.add(ignoredFile);