From 366b2ed3957aa01de63a4628b799792412ba1d1b Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Wed, 8 Nov 2023 12:46:59 +0100 Subject: [PATCH] Add newly created file to file list cache --- web/space.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/space.ts b/web/space.ts index 5fe998d..882aa8b 100644 --- a/web/space.ts +++ b/web/space.ts @@ -128,13 +128,19 @@ export class Space { ): Promise { try { this.saving = true; - return fileMetaToPageMeta( + const pageMeta = fileMetaToPageMeta( await this.spacePrimitives.writeFile( `${name}.md`, new TextEncoder().encode(text), 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 { this.saving = false; }