getNoteList function
Implementation
Future<Map> getNoteList(BuildContext context, Widget childPage) async {
final loggedIn = await loginIfRequired(context);
String webId = await getWebId() as String;
webId = webId.replaceAll(profCard, '');
if (loggedIn) {
final dataDirPath = await getDataDirPath();
final dataDirUrl = await getDirUrl(dataDirPath);
// Why do we need the additional `/`? (20250714 gjw)
final notesDirUrl = '$dataDirUrl/';
// Check if the directory exists.
bool resExist = await checkResourceStatus(notesDirUrl, fileFlag: false);
if (resExist) {
//debugPrint('Data: $dataDirUrl');
final res = await getResourcesInContainer(notesDirUrl);
// debugPrint(res.toString());
Map notesMap = {};
// Loop through the list of files to get the file names
for (final fileName in res.files) {
// Read file content
//debugPrint('Read: $fileName');
String noteContent =
await readPod(fileName.replaceAll(webId, ''), context, childPage);
//debugPrint('NoteInfoMap: $fileName');
notesMap[fileName] = noteInfoMap(noteContent);
//debugPrint('$fileName => ${notesMap[fileName]}');
}
// final filteredMap = filterTreatments(treatmentMap, type);
return notesMap;
} else {
debugPrint('WARN: No data directory for the notes: $notesDirUrl.');
return {};
}
} else {
debugPrint('WARN: Not logged in when finding the list of notes.');
return {};
}
}