mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 15:33:11 +01:00
fix: no env select issue (#3247)
This commit is contained in:
parent
5c5e3d18fc
commit
ce8ebb0c1a
@ -19,7 +19,7 @@ import {
|
||||
runRequestEvent,
|
||||
scriptEnvironmentUpdateEvent
|
||||
} from 'providers/ReduxStore/slices/collections';
|
||||
import { collectionAddEnvFileEvent, openCollectionEvent, hydrateCollectionsWithUiStateSnapshot } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import { collectionAddEnvFileEvent, openCollectionEvent, hydrateCollectionWithUiStateSnapshot } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import toast from 'react-hot-toast';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { isElectron } from 'utils/common/platform';
|
||||
@ -150,7 +150,7 @@ const useIpcEvents = () => {
|
||||
});
|
||||
|
||||
const removeSnapshotHydrationListener = ipcRenderer.on('main:hydrate-app-with-ui-state-snapshot', (val) => {
|
||||
dispatch(hydrateCollectionsWithUiStateSnapshot(val));
|
||||
dispatch(hydrateCollectionWithUiStateSnapshot(val));
|
||||
})
|
||||
|
||||
return () => {
|
||||
|
@ -971,17 +971,19 @@ export const selectEnvironment = (environmentUid, collectionUid) => (dispatch, g
|
||||
}
|
||||
|
||||
const collectionCopy = cloneDeep(collection);
|
||||
if (environmentUid) {
|
||||
const environment = findEnvironmentInCollection(collectionCopy, environmentUid);
|
||||
if (environment) {
|
||||
ipcRenderer.invoke('renderer:update-ui-state-snapshot', { type: 'COLLECTION_ENVIRONMENT', data: { collectionPath: collection?.pathname, environmentName: environment?.name } })
|
||||
dispatch(_selectEnvironment({ environmentUid, collectionUid }));
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
return reject(new Error('Environment not found'));
|
||||
}
|
||||
}
|
||||
|
||||
const environmentName = environmentUid
|
||||
? findEnvironmentInCollection(collectionCopy, environmentUid)?.name
|
||||
: null;
|
||||
|
||||
if (environmentUid && !environmentName) {
|
||||
return reject(new Error('Environment not found'));
|
||||
}
|
||||
|
||||
ipcRenderer.invoke('renderer:update-ui-state-snapshot', { type: 'COLLECTION_ENVIRONMENT', data: { collectionPath: collection?.pathname, environmentName }});
|
||||
|
||||
dispatch(_selectEnvironment({ environmentUid, collectionUid }));
|
||||
resolve();
|
||||
});
|
||||
};
|
||||
|
||||
@ -1146,7 +1148,7 @@ export const saveCollectionSecurityConfig = (collectionUid, securityConfig) => (
|
||||
};
|
||||
|
||||
|
||||
export const hydrateCollectionsWithUiStateSnapshot = (payload) => (dispatch, getState) => {
|
||||
export const hydrateCollectionWithUiStateSnapshot = (payload) => (dispatch, getState) => {
|
||||
const collectionSnapshotData = payload;
|
||||
return new Promise((resolve, reject) => {
|
||||
const state = getState();
|
||||
|
@ -25,11 +25,11 @@ const { moveRequestUid, deleteRequestUid } = require('../cache/requestUids');
|
||||
const { deleteCookiesForDomain, getDomainsWithCookies } = require('../utils/cookies');
|
||||
const EnvironmentSecretsStore = require('../store/env-secrets');
|
||||
const CollectionSecurityStore = require('../store/collection-security');
|
||||
const UiStateSnapshot = require('../store/ui-state-snapshot');
|
||||
const UiStateSnapshotStore = require('../store/ui-state-snapshot');
|
||||
|
||||
const environmentSecretsStore = new EnvironmentSecretsStore();
|
||||
const collectionSecurityStore = new CollectionSecurityStore();
|
||||
const UiStateSnapshotStore = new UiStateSnapshot();
|
||||
const uiStateSnapshotStore = new UiStateSnapshotStore();
|
||||
|
||||
const envHasSecrets = (environment = {}) => {
|
||||
const secrets = _.filter(environment.variables, (v) => v.secret);
|
||||
@ -700,7 +700,7 @@ const registerRendererEventHandlers = (mainWindow, watcher, lastOpenedCollection
|
||||
|
||||
ipcMain.handle('renderer:update-ui-state-snapshot', (event, { type, data }) => {
|
||||
try {
|
||||
UiStateSnapshotStore.update({ type, data });
|
||||
uiStateSnapshotStore.update({ type, data });
|
||||
} catch (error) {
|
||||
throw new Error(error.message);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
const Store = require('electron-store');
|
||||
|
||||
class UiStateSnapshot {
|
||||
class UiStateSnapshotStore {
|
||||
constructor() {
|
||||
this.store = new Store({
|
||||
name: 'ui-state-snapshot',
|
||||
@ -57,4 +57,4 @@ class UiStateSnapshot {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UiStateSnapshot;
|
||||
module.exports = UiStateSnapshotStore;
|
||||
|
Loading…
Reference in New Issue
Block a user