From a06434cae8fa4112a874a9b7a0c1d0fd9280d202 Mon Sep 17 00:00:00 2001 From: keiya sasaki Date: Wed, 25 Jan 2023 12:21:11 +0900 Subject: [PATCH] fix: plugin instance runTimes property (#405) fix: runtimes --- .../molecules/Visualizer/usePluginInstances.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/molecules/Visualizer/usePluginInstances.ts b/src/components/molecules/Visualizer/usePluginInstances.ts index c0cc55bcda..2d4d47e4f6 100644 --- a/src/components/molecules/Visualizer/usePluginInstances.ts +++ b/src/components/molecules/Visualizer/usePluginInstances.ts @@ -30,9 +30,9 @@ export default ({ alignSystem, floatingWidgets, blocks }: Props) => { const runTimesCache = useMemo>(() => new Map(), []); const runTimesCacheHandler = useMemo( () => ({ - get: (id: string) => runTimesCache.get(id), - increment: (id: string) => runTimesCache.set(id, (runTimesCache.get(id) || 0) + 1), - decrement: (id: string) => runTimesCache.set(id, (runTimesCache.get(id) || 0) - 1), + get: (id: string) => runTimesCache.get(id) || 0, + increment: (id: string) => runTimesCache.set(id, runTimesCacheHandler.get(id) + 1), + decrement: (id: string) => runTimesCache.set(id, runTimesCacheHandler.get(id) - 1), clear: (id: string) => runTimesCache.set(id, 0), clearAll: () => runTimesCache.clear(), }), @@ -60,7 +60,7 @@ export default ({ alignSystem, floatingWidgets, blocks }: Props) => { extensionId: widget.extensionId ?? "", extensionType: "widget", get runTimes() { - return runTimesCache.get(widget.id); + return runTimesCacheHandler.get(widget.id); }, }); }); @@ -81,7 +81,7 @@ export default ({ alignSystem, floatingWidgets, blocks }: Props) => { extensionId: widget.extensionId ?? "", extensionType: "widget", get runTimes() { - return runTimesCache.get(widget.id); + return runTimesCacheHandler.get(widget.id); }, }); }); @@ -96,14 +96,14 @@ export default ({ alignSystem, floatingWidgets, blocks }: Props) => { extensionId: block.extensionId ?? "", extensionType: "block", get runTimes() { - return runTimesCache.get(block.id); + return runTimesCacheHandler.get(block.id); }, }); }); } pluginInstancesMeta.current = instances; - }, [alignSystem, floatingWidgets, blocks, runTimesCache]); + }, [alignSystem, floatingWidgets, blocks, runTimesCacheHandler]); const pluginMessageSenders = useRef void>>(new Map());