diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/global-environments.js b/packages/bruno-app/src/providers/ReduxStore/slices/global-environments.js index 7cc19a5a3..c93d6b6bd 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/global-environments.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/global-environments.js @@ -92,9 +92,7 @@ export const addGlobalEnvironment = ({ name, variables = [] }) => (dispatch, get const uid = uuid(); ipcRenderer .invoke('renderer:create-global-environment', { name, uid, variables }) - .then( - dispatch(_addGlobalEnvironment({ name, uid, variables })) - ) + .then(() => dispatch(_addGlobalEnvironment({ name, uid, variables }))) .then(resolve) .catch(reject); }); diff --git a/packages/bruno-electron/src/store/global-environments.js b/packages/bruno-electron/src/store/global-environments.js index 7c0540d95..e8c03c434 100644 --- a/packages/bruno-electron/src/store/global-environments.js +++ b/packages/bruno-electron/src/store/global-environments.js @@ -63,6 +63,10 @@ class GlobalEnvironmentsStore { addGlobalEnvironment({ uid, name, variables = [] }) { let globalEnvironments = this.getGlobalEnvironments(); + const existingEnvironment = globalEnvironments.find(env => env?.name == name); + if (existingEnvironment) { + throw new Error('Environment with the same name already exists'); + } globalEnvironments.push({ uid, name,