Skip to content

Commit

Permalink
fix: plugin instance runTimes property (#405)
Browse files Browse the repository at this point in the history
fix: runtimes
  • Loading branch information
keiya01 committed Jan 25, 2023
1 parent 17d7870 commit a06434c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/components/molecules/Visualizer/usePluginInstances.ts
Expand Up @@ -30,9 +30,9 @@ export default ({ alignSystem, floatingWidgets, blocks }: Props) => {
const runTimesCache = useMemo<Map<string, number>>(() => 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(),
}),
Expand Down Expand Up @@ -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);
},
});
});
Expand All @@ -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);
},
});
});
Expand All @@ -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<Map<string, (msg: any) => void>>(new Map());

Expand Down

0 comments on commit a06434c

Please sign in to comment.