Minor refactoring

This commit is contained in:
Vishesh Handa
2021-07-26 16:51:58 +02:00
parent d9ad163780
commit e3526b4911
3 changed files with 16 additions and 11 deletions

View File

@ -116,7 +116,8 @@ class Note with NotesNotifier {
static final _linksLoader = LinksLoader(); static final _linksLoader = LinksLoader();
Note(this.parent, this._filePath) { Note(this.parent, this._filePath) {
noteSerializer = NoteSerializer.fromConfig(parent.config); var settings = NoteSerializationSettings.fromConfig(parent.config);
noteSerializer = NoteSerializer.fromConfig(settings);
} }
Note.newNote( Note.newNote(
@ -127,7 +128,8 @@ class Note with NotesNotifier {
created = DateTime.now(); created = DateTime.now();
_loadState = NoteLoadState.Loaded; _loadState = NoteLoadState.Loaded;
_fileFormat = NoteFileFormat.Markdown; _fileFormat = NoteFileFormat.Markdown;
noteSerializer = NoteSerializer.fromConfig(parent.config); var settings = NoteSerializationSettings.fromConfig(parent.config);
noteSerializer = NoteSerializer.fromConfig(settings);
if (extraProps.isNotEmpty) { if (extraProps.isNotEmpty) {
extraProps.forEach((key, value) { extraProps.forEach((key, value) {

View File

@ -44,18 +44,20 @@ class NoteSerializationSettings {
bool tagsHaveHash = false; bool tagsHaveHash = false;
SettingsTitle titleSettings = SettingsTitle.Default; SettingsTitle titleSettings = SettingsTitle.Default;
NoteSerializationSettings.fromConfig(NotesFolderConfig config) {
modifiedKey = config.yamlModifiedKey;
createdKey = config.yamlCreatedKey;
tagsKey = config.yamlTagsKey;
titleSettings = config.titleSettings;
}
NoteSerializationSettings();
} }
class NoteSerializer implements NoteSerializerInterface { class NoteSerializer implements NoteSerializerInterface {
var settings = NoteSerializationSettings(); var settings = NoteSerializationSettings();
NoteSerializer.fromConfig(NotesFolderConfig config) { NoteSerializer.fromConfig(this.settings);
settings.modifiedKey = config.yamlModifiedKey;
settings.createdKey = config.yamlCreatedKey;
settings.tagsKey = config.yamlTagsKey;
settings.titleSettings = config.titleSettings;
}
NoteSerializer.raw(); NoteSerializer.raw();
@override @override

View File

@ -211,8 +211,9 @@ class NoteOutputExample extends StatelessWidget {
var settings = Provider.of<Settings>(context); var settings = Provider.of<Settings>(context);
var doc = MdYamlDoc(); var doc = MdYamlDoc();
NoteSerializer.fromConfig(NotesFolderConfig.fromSettings(null, settings)) var folderConfig = NotesFolderConfig.fromSettings(null, settings);
.encode(note, doc); var serialSettings = NoteSerializationSettings.fromConfig(folderConfig);
NoteSerializer.fromConfig(serialSettings).encode(note, doc);
var codec = MarkdownYAMLCodec(); var codec = MarkdownYAMLCodec();
var noteStr = codec.encode(doc); var noteStr = codec.encode(doc);