diff --git a/packages/bruno-app/src/components/CollectionSettings/Presets/index.js b/packages/bruno-app/src/components/CollectionSettings/Presets/index.js index e6b4bcec1..70fb8e98f 100644 --- a/packages/bruno-app/src/components/CollectionSettings/Presets/index.js +++ b/packages/bruno-app/src/components/CollectionSettings/Presets/index.js @@ -3,7 +3,8 @@ import { useFormik } from 'formik'; import { useDispatch } from 'react-redux'; import StyledWrapper from './StyledWrapper'; import toast from 'react-hot-toast'; -import { updateCollectionPresets } from 'providers/ReduxStore/slices/collections/actions'; +import { updateBrunoConfig } from 'providers/ReduxStore/slices/collections/actions'; +import cloneDeep from 'lodash/cloneDeep'; const PresetsSettings = ({ collection }) => { const dispatch = useDispatch(); @@ -18,7 +19,9 @@ const PresetsSettings = ({ collection }) => { defaultRequestUrl: defaultPresets.defaultRequestUrl || '' }, onSubmit: (newPresets) => { - dispatch(updateCollectionPresets(newPresets, collection.uid)); + const brunoConfig = cloneDeep(collection.brunoConfig); + brunoConfig.presets = newPresets; + dispatch(updateBrunoConfig(brunoConfig, collection.uid)); toast.success('Collection presets updated'); } }); diff --git a/packages/bruno-app/src/providers/App/useIpcEvents.js b/packages/bruno-app/src/providers/App/useIpcEvents.js index 6cef0bfa2..8e87b1cf9 100644 --- a/packages/bruno-app/src/providers/App/useIpcEvents.js +++ b/packages/bruno-app/src/providers/App/useIpcEvents.js @@ -12,8 +12,7 @@ import { collectionRenamedEvent, runRequestEvent, runFolderEvent, - brunoConfigUpdateEvent, - collectionPresetsUpdatedEvent + brunoConfigUpdateEvent } from 'providers/ReduxStore/slices/collections'; import { updatePreferences } from 'providers/ReduxStore/slices/app'; import toast from 'react-hot-toast'; @@ -108,10 +107,6 @@ const useIpcEvents = () => { dispatch(collectionRenamedEvent(val)); }); - const removeCollectionPresetsUpdatedListener = ipcRenderer.on('main:collection-presets-updated', (val) => { - dispatch(collectionPresetsUpdatedEvent(val)); - }); - const removeRunFolderEventListener = ipcRenderer.on('main:run-folder-event', (val) => { dispatch(runFolderEvent(val)); }); @@ -143,7 +138,6 @@ const useIpcEvents = () => { removeDisplayErrorListener(); removeScriptEnvUpdateListener(); removeCollectionRenamedListener(); - removeCollectionPresetsUpdatedListener(); removeRunFolderEventListener(); removeRunRequestEventListener(); removeProcessEnvUpdatesListener(); diff --git a/packages/bruno-electron/src/ipc/collection.js b/packages/bruno-electron/src/ipc/collection.js index f5d5357ab..ab92d50bd 100644 --- a/packages/bruno-electron/src/ipc/collection.js +++ b/packages/bruno-electron/src/ipc/collection.js @@ -94,28 +94,6 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection } }); - // update collection properties - ipcMain.handle('renderer:update-collection-presets', async (event, newPresets, collectionPathname) => { - try { - const brunoJsonFilePath = path.join(collectionPathname, 'bruno.json'); - const content = fs.readFileSync(brunoJsonFilePath, 'utf8'); - const json = JSON.parse(content); - - json.presets = newPresets; - - const newContent = await stringifyJson(json); - await writeFile(brunoJsonFilePath, newContent); - - // fire an event in renderer to change the collection properties - mainWindow.webContents.send('main:collection-presets-updated', { - collectionPathname, - newPresets - }); - } catch (error) { - return Promise.reject(error); - } - }); - ipcMain.handle('renderer:save-collection-root', async (event, collectionPathname, collectionRoot) => { try { const collectionBruFilePath = path.join(collectionPathname, 'collection.bru');