1
0

Add newly created file to file list cache

This commit is contained in:
Zef Hemel 2023-11-08 12:46:59 +01:00
parent ed0c0d9616
commit 366b2ed395

View File

@ -128,13 +128,19 @@ export class Space {
): Promise<PageMeta> { ): Promise<PageMeta> {
try { try {
this.saving = true; this.saving = true;
return fileMetaToPageMeta( const pageMeta = fileMetaToPageMeta(
await this.spacePrimitives.writeFile( await this.spacePrimitives.writeFile(
`${name}.md`, `${name}.md`,
new TextEncoder().encode(text), new TextEncoder().encode(text),
selfUpdate, selfUpdate,
), ),
); );
if (!this.cachedPageList.find((page) => page.name === pageMeta.name)) {
// New page, let's cache it
this.cachedPageList.push(pageMeta);
}
// Note: we don't do very elaborate cache invalidation work here, quite quickly the cache will be flushed anyway
return pageMeta;
} finally { } finally {
this.saving = false; this.saving = false;
} }