From 5959c088737fd521fba71b9cb2a32a50abc27975 Mon Sep 17 00:00:00 2001 From: alt0 Date: Thu, 18 Aug 2022 12:16:12 +0800 Subject: [PATCH 1/2] fix: remove asyncBlock cache --- libs/components/editor-core/src/editor/editor.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libs/components/editor-core/src/editor/editor.ts b/libs/components/editor-core/src/editor/editor.ts index 1d1cc95684..2cd379bb26 100644 --- a/libs/components/editor-core/src/editor/editor.ts +++ b/libs/components/editor-core/src/editor/editor.ts @@ -1,6 +1,5 @@ /* eslint-disable max-lines */ import HotKeys from 'hotkeys-js'; -import LRUCache from 'lru-cache'; import type { PatchNode } from '@toeverything/components/ui'; import type { @@ -46,10 +45,7 @@ export interface EditorCtorProps { } export class Editor implements Virgo { - private _cacheManager = new LRUCache>({ - max: 8192, - ttl: 1000 * 60 * 30, - }); + private _cacheManager = new Map>(); public mouseManager = new MouseManager(this); public selectionManager = new SelectionManager(this); public keyboardManager = new KeyboardManager(this); From 68cadca5ca84ad5d7d0b5b90c26aa1508ea8ccf7 Mon Sep 17 00:00:00 2001 From: alt0 Date: Thu, 18 Aug 2022 14:29:44 +0800 Subject: [PATCH 2/2] fix: if delete block, clear cache --- libs/components/editor-core/src/editor/editor.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libs/components/editor-core/src/editor/editor.ts b/libs/components/editor-core/src/editor/editor.ts index 2cd379bb26..e85db2ba65 100644 --- a/libs/components/editor-core/src/editor/editor.ts +++ b/libs/components/editor-core/src/editor/editor.ts @@ -230,7 +230,12 @@ export class Editor implements Virgo { return await services.api.editorBlock.update(patches); }, remove: async ({ workspace, id }: WorkspaceAndBlockId) => { - return await services.api.editorBlock.delete({ workspace, id }); + const ret = await services.api.editorBlock.delete({ + workspace, + id, + }); + this._cacheManager.delete(id); + return ret; }, observe: async ( { workspace, id }: WorkspaceAndBlockId,