From 7b1f6b52c7b6d5750421748465d2d578a14d0f6c Mon Sep 17 00:00:00 2001 From: bobzel Date: Wed, 7 Dec 2022 22:13:36 -0500 Subject: simplify update cache --- src/client/DocServer.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/client/DocServer.ts b/src/client/DocServer.ts index 5a34fcf11..e61de86be 100644 --- a/src/client/DocServer.ts +++ b/src/client/DocServer.ts @@ -29,12 +29,14 @@ export namespace DocServer { let _cache: { [id: string]: RefField | Promise> } = {}; export function UPDATE_SERVER_CACHE(print: boolean = false) { - const strings: string[] = []; - Array.from(Object.keys(_cache)).forEach(key => { - const doc = _cache[key]; - if (doc instanceof Doc) strings.push(StrCast(doc.author) + ' ' + StrCast(doc.title) + ' ' + StrCast(Doc.GetT(doc, 'title', 'string', true))); - }); - print && strings.sort().forEach((str, i) => console.log(i.toString() + ' ' + str)); + if (print) { + const strings: string[] = []; + Array.from(Object.keys(_cache)).forEach(key => { + const doc = _cache[key]; + if (doc instanceof Doc) strings.push(StrCast(doc.author) + ' ' + StrCast(doc.title) + ' ' + StrCast(Doc.GetT(doc, 'title', 'string', true))); + }); + strings.sort().forEach((str, i) => console.log(i.toString() + ' ' + str)); + } rp.post(Utils.prepend('/setCacheDocumentIds'), { body: { cacheDocumentIds: Array.from(Object.keys(_cache)).join(';'), -- cgit v1.2.3-70-g09d2