mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-25 00:00:26 +08:00
Minor refactoring
This commit is contained in:
@ -116,7 +116,8 @@ class Note with NotesNotifier {
|
||||
static final _linksLoader = LinksLoader();
|
||||
|
||||
Note(this.parent, this._filePath) {
|
||||
noteSerializer = NoteSerializer.fromConfig(parent.config);
|
||||
var settings = NoteSerializationSettings.fromConfig(parent.config);
|
||||
noteSerializer = NoteSerializer.fromConfig(settings);
|
||||
}
|
||||
|
||||
Note.newNote(
|
||||
@ -127,7 +128,8 @@ class Note with NotesNotifier {
|
||||
created = DateTime.now();
|
||||
_loadState = NoteLoadState.Loaded;
|
||||
_fileFormat = NoteFileFormat.Markdown;
|
||||
noteSerializer = NoteSerializer.fromConfig(parent.config);
|
||||
var settings = NoteSerializationSettings.fromConfig(parent.config);
|
||||
noteSerializer = NoteSerializer.fromConfig(settings);
|
||||
|
||||
if (extraProps.isNotEmpty) {
|
||||
extraProps.forEach((key, value) {
|
||||
|
@ -44,18 +44,20 @@ class NoteSerializationSettings {
|
||||
bool tagsHaveHash = false;
|
||||
|
||||
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 {
|
||||
var settings = NoteSerializationSettings();
|
||||
|
||||
NoteSerializer.fromConfig(NotesFolderConfig config) {
|
||||
settings.modifiedKey = config.yamlModifiedKey;
|
||||
settings.createdKey = config.yamlCreatedKey;
|
||||
settings.tagsKey = config.yamlTagsKey;
|
||||
settings.titleSettings = config.titleSettings;
|
||||
}
|
||||
|
||||
NoteSerializer.fromConfig(this.settings);
|
||||
NoteSerializer.raw();
|
||||
|
||||
@override
|
||||
|
@ -211,8 +211,9 @@ class NoteOutputExample extends StatelessWidget {
|
||||
var settings = Provider.of<Settings>(context);
|
||||
|
||||
var doc = MdYamlDoc();
|
||||
NoteSerializer.fromConfig(NotesFolderConfig.fromSettings(null, settings))
|
||||
.encode(note, doc);
|
||||
var folderConfig = NotesFolderConfig.fromSettings(null, settings);
|
||||
var serialSettings = NoteSerializationSettings.fromConfig(folderConfig);
|
||||
NoteSerializer.fromConfig(serialSettings).encode(note, doc);
|
||||
|
||||
var codec = MarkdownYAMLCodec();
|
||||
var noteStr = codec.encode(doc);
|
||||
|
Reference in New Issue
Block a user