Convert IgnoreReason to an enum

This commit is contained in:
Vishesh Handa
2020-11-09 12:00:59 +01:00
parent eac5a296ab
commit aaf96c82d1
2 changed files with 11 additions and 7 deletions

View File

@ -12,9 +12,14 @@ import 'note.dart';
import 'notes_folder.dart';
import 'notes_folder_notifier.dart';
enum IgnoreReason {
HiddenFile,
InvalidExtension,
}
class IgnoredFile {
String filePath;
String reason;
IgnoreReason reason;
IgnoredFile({@required this.filePath, @required this.reason});
@ -242,27 +247,26 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
// FIXME: Why does 'tr' not work over here
var ignoredFile = IgnoredFile(
filePath: fsEntity.path,
reason: "Starts with a .",
reason: IgnoreReason.HiddenFile,
);
_ignoredFiles.add(ignoredFile);
Log.v("Ignoring file", props: {
"path": ignoredFile.filePath,
"reason": ignoredFile.reason,
"reason": ignoredFile.reason.toString(),
});
continue;
}
if (!NoteFileFormatInfo.isAllowedFileName(note.filePath)) {
var ignoredFile = IgnoredFile(
filePath: fsEntity.path,
reason: "Doesn't end with one of the following - " +
NoteFileFormatInfo.allowedExtensions().join(' '),
reason: IgnoreReason.InvalidExtension,
);
_ignoredFiles.add(ignoredFile);
// Log.v("Ignoring file", props: {
// "path": ignoredFile.filePath,
// "reason": ignoredFile.reason,
// "reason": ignoredFile.reason.toString(),
// });
continue;
}

View File

@ -45,7 +45,7 @@ class _FileSystemScreenState extends State<FileSystemScreen> {
builder: (BuildContext context) {
return AlertDialog(
title: Text(tr("screens.filesystem.ignoredFile.title")),
content: Text(ignoredFile.reason),
content: Text(ignoredFile.reason.toString()),
actions: <Widget>[
FlatButton(
onPressed: () async {