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.dart';
import 'notes_folder_notifier.dart'; import 'notes_folder_notifier.dart';
enum IgnoreReason {
HiddenFile,
InvalidExtension,
}
class IgnoredFile { class IgnoredFile {
String filePath; String filePath;
String reason; IgnoreReason reason;
IgnoredFile({@required this.filePath, @required this.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 // FIXME: Why does 'tr' not work over here
var ignoredFile = IgnoredFile( var ignoredFile = IgnoredFile(
filePath: fsEntity.path, filePath: fsEntity.path,
reason: "Starts with a .", reason: IgnoreReason.HiddenFile,
); );
_ignoredFiles.add(ignoredFile); _ignoredFiles.add(ignoredFile);
Log.v("Ignoring file", props: { Log.v("Ignoring file", props: {
"path": ignoredFile.filePath, "path": ignoredFile.filePath,
"reason": ignoredFile.reason, "reason": ignoredFile.reason.toString(),
}); });
continue; continue;
} }
if (!NoteFileFormatInfo.isAllowedFileName(note.filePath)) { if (!NoteFileFormatInfo.isAllowedFileName(note.filePath)) {
var ignoredFile = IgnoredFile( var ignoredFile = IgnoredFile(
filePath: fsEntity.path, filePath: fsEntity.path,
reason: "Doesn't end with one of the following - " + reason: IgnoreReason.InvalidExtension,
NoteFileFormatInfo.allowedExtensions().join(' '),
); );
_ignoredFiles.add(ignoredFile); _ignoredFiles.add(ignoredFile);
// Log.v("Ignoring file", props: { // Log.v("Ignoring file", props: {
// "path": ignoredFile.filePath, // "path": ignoredFile.filePath,
// "reason": ignoredFile.reason, // "reason": ignoredFile.reason.toString(),
// }); // });
continue; continue;
} }

View File

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