forked from extern/bruno
removed custom ipc event
This commit is contained in:
parent
cbfd7fa5f4
commit
e658629482
@ -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');
|
||||
}
|
||||
});
|
||||
|
@ -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();
|
||||
|
@ -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');
|
||||
|
Loading…
Reference in New Issue
Block a user