mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-09-17 00:42:29 +08:00
Add a .gitjournal.yaml file in a folder
This file will be added to save the settings of how we want that folder to behave. For example - default Editor, view, sorting mode, etc. This feature is currently disabled as it will only be a part of the pro mode.
This commit is contained in:
@ -7,6 +7,7 @@ import 'package:fimber/fimber.dart';
|
||||
import 'package:git_bindings/git_bindings.dart';
|
||||
|
||||
import 'package:gitjournal/core/note.dart';
|
||||
import 'package:gitjournal/core/notes_folder.dart';
|
||||
import 'package:gitjournal/core/notes_folder_fs.dart';
|
||||
import 'package:gitjournal/settings.dart';
|
||||
|
||||
@ -55,6 +56,18 @@ class GitNoteRepository {
|
||||
return NoteRepoResult(noteFilePath: folder.folderPath, error: false);
|
||||
}
|
||||
|
||||
Future<NoteRepoResult> addFolderConfig(NotesFolderConfig config) async {
|
||||
var pathSpec = config.folder.pathSpec();
|
||||
pathSpec = pathSpec.isNotEmpty ? pathSpec : '/';
|
||||
|
||||
await _gitRepo.add(".");
|
||||
await _gitRepo.commit(
|
||||
message: "Update folder config for $pathSpec",
|
||||
);
|
||||
|
||||
return NoteRepoResult(noteFilePath: config.folder.folderPath, error: false);
|
||||
}
|
||||
|
||||
Future<NoteRepoResult> renameFolder(
|
||||
String oldFullPath,
|
||||
String newFullPath,
|
||||
|
@ -1,6 +1,7 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fimber/fimber.dart';
|
||||
import 'package:gitjournal/features.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:path/path.dart';
|
||||
import 'package:synchronized/synchronized.dart';
|
||||
@ -18,6 +19,7 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
|
||||
List<NotesFolderFS> _folders = [];
|
||||
|
||||
Map<String, dynamic> _entityMap = {};
|
||||
NotesFolderConfig _config;
|
||||
|
||||
NotesFolderFS(this._parent, this._folderPath);
|
||||
|
||||
@ -149,6 +151,11 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
|
||||
Future<void> _load() async {
|
||||
Set<String> pathsFound = {};
|
||||
|
||||
// Load the Folder config if exists
|
||||
if (Features.perFolderConfig) {
|
||||
_config = await NotesFolderConfig.fromFS(this);
|
||||
}
|
||||
|
||||
final dir = Directory(folderPath);
|
||||
var lister = dir.list(recursive: false, followLinks: false);
|
||||
await for (var fsEntity in lister) {
|
||||
@ -344,11 +351,18 @@ class NotesFolderFS with NotesFolderNotifier implements NotesFolder {
|
||||
|
||||
@override
|
||||
NotesFolderConfig get config {
|
||||
return NotesFolderConfig.fromSettings();
|
||||
if (Features.perFolderConfig && _config != null) {
|
||||
return _config;
|
||||
}
|
||||
return NotesFolderConfig.fromSettings(this);
|
||||
}
|
||||
|
||||
@override
|
||||
set config(NotesFolderConfig conf) {
|
||||
conf.save();
|
||||
set config(NotesFolderConfig config) {
|
||||
if (Features.perFolderConfig) {
|
||||
_config = config;
|
||||
} else {
|
||||
config.saveToSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,12 +35,12 @@ class VirtualNotesFolder with NotesFolderNotifier implements NotesFolder {
|
||||
|
||||
@override
|
||||
NotesFolderConfig get config {
|
||||
return NotesFolderConfig.fromSettings();
|
||||
return NotesFolderConfig.fromSettings(fsFolder);
|
||||
}
|
||||
|
||||
@override
|
||||
set config(NotesFolderConfig conf) {
|
||||
assert(false, "A Virtual Notes Folder Config cannot change");
|
||||
conf.save();
|
||||
conf.saveToSettings();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user