From f31f6273a6a36fea1d4941503327c390894a824b Mon Sep 17 00:00:00 2001 From: Piotr Gawron <p.gawron@atcomp.pl> Date: Fri, 10 May 2024 12:44:38 +0200 Subject: [PATCH] don't add duplicated id --- src/redux/plugins/plugins.reducers.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/redux/plugins/plugins.reducers.ts b/src/redux/plugins/plugins.reducers.ts index 4f373601..f3d74473 100644 --- a/src/redux/plugins/plugins.reducers.ts +++ b/src/redux/plugins/plugins.reducers.ts @@ -1,4 +1,5 @@ import type { ActionReducerMapBuilder } from '@reduxjs/toolkit'; +import { ZERO } from '@/constants/common'; import { getAllPlugins, registerPlugin } from './plugins.thunks'; import type { PluginsState, @@ -15,7 +16,9 @@ export const removePluginReducer = (state: PluginsState, action: RemovePluginAct export const registerPluginReducer = (builder: ActionReducerMapBuilder<PluginsState>): void => { builder.addCase(registerPlugin.pending, (state, action) => { const { hash } = action.meta.arg; - state.activePlugins.pluginsId.push(hash); + if (state.activePlugins.pluginsId.indexOf(hash) < ZERO) { + state.activePlugins.pluginsId.push(hash); + } }); builder.addCase(registerPlugin.fulfilled, (state, action) => { if (action.payload) { -- GitLab