mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
NotesFolder: Allow only one folder to be loaded
We don't always need to load everything recursively.
This commit is contained in:
@ -78,8 +78,19 @@ class NotesFolder with ChangeNotifier {
|
|||||||
|
|
||||||
// FIXME: This asynchronously loads everything. Maybe it should just list them, and the individual _entities
|
// FIXME: This asynchronously loads everything. Maybe it should just list them, and the individual _entities
|
||||||
// should be loaded as required?
|
// should be loaded as required?
|
||||||
// FIXME: This should not reconstruct the Notes or NotesFolders once constructed.
|
|
||||||
Future<void> loadRecursively() async {
|
Future<void> loadRecursively() async {
|
||||||
|
await load();
|
||||||
|
_entities.forEach((e) {
|
||||||
|
if (e.isFolder) {
|
||||||
|
e.folder.loadRecursively();
|
||||||
|
} else {
|
||||||
|
e.note.load();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// FIXME: This should not reconstruct the Notes or NotesFolders once constructed.
|
||||||
|
Future<void> load() async {
|
||||||
final dir = Directory(folderPath);
|
final dir = Directory(folderPath);
|
||||||
_entities.forEach((e) {
|
_entities.forEach((e) {
|
||||||
if (e.isFolder) {
|
if (e.isFolder) {
|
||||||
@ -98,7 +109,6 @@ class NotesFolder with ChangeNotifier {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
subFolder.addListener(_entityChanged);
|
subFolder.addListener(_entityChanged);
|
||||||
await subFolder.loadRecursively();
|
|
||||||
|
|
||||||
var noteFSEntity = NoteFSEntity(folder: subFolder);
|
var noteFSEntity = NoteFSEntity(folder: subFolder);
|
||||||
_entities.add(noteFSEntity);
|
_entities.add(noteFSEntity);
|
||||||
@ -110,7 +120,6 @@ class NotesFolder with ChangeNotifier {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
note.addListener(_entityChanged);
|
note.addListener(_entityChanged);
|
||||||
await note.load();
|
|
||||||
|
|
||||||
var noteFSEntity = NoteFSEntity(note: note);
|
var noteFSEntity = NoteFSEntity(note: note);
|
||||||
_entities.add(noteFSEntity);
|
_entities.add(noteFSEntity);
|
||||||
|
Reference in New Issue
Block a user