Add basic Notes UI

This commit is contained in:
Bruno Bernardino
2024-04-26 14:31:25 +01:00
parent 2920de90b6
commit 3f5422f8eb
14 changed files with 849 additions and 104 deletions

View File

@@ -75,6 +75,17 @@ async function getPathEntries(userId: string, path: string): Promise<Deno.DirEnt
}
}
// Ensure the Notes or Photos directories exist, if being requested
if (path === '/Notes/' || path === '/Photos/') {
try {
await Deno.stat(rootPath);
} catch (error) {
if (error.toString().includes('NotFound')) {
await Deno.mkdir(rootPath, { recursive: true });
}
}
}
const entries: Deno.DirEntry[] = [];
for await (const dirEntry of Deno.readDir(rootPath)) {
@@ -159,6 +170,24 @@ export async function createFile(
return true;
}
export async function updateFile(
userId: string,
path: string,
name: string,
contents: string,
): Promise<boolean> {
const rootPath = join(getFilesRootPath(), userId, path);
try {
await Deno.writeTextFile(join(rootPath, name), contents, { append: false, createNew: false });
} catch (error) {
console.error(error);
return false;
}
return true;
}
export async function getFile(
userId: string,
path: string,