diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js index 38e3c30ed..c5a083e6c 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -21,7 +21,7 @@ import { } from 'utils/collections'; import { collectionSchema, itemSchema, environmentSchema, environmentsSchema } from '@usebruno/schema'; import { waitForNextTick } from 'utils/common'; -import { getDirectoryName, isWindowsOS } from 'utils/common/platform'; +import { getDirectoryName, isWindowsOS, PATH_SEPARATOR } from 'utils/common/platform'; import { sendNetworkRequest, cancelNetworkRequest } from 'utils/network'; import { @@ -31,7 +31,6 @@ import { requestCancelled, responseReceived, newItem as _newItem, - renameItem as _renameItem, cloneItem as _cloneItem, deleteItem as _deleteItem, saveRequest as _saveRequest, @@ -48,8 +47,6 @@ import { resolveRequestFilename } from 'utils/common/platform'; import { parseQueryParams, splitOnFirst } from 'utils/url/index'; import { each } from 'lodash'; -const PATH_SEPARATOR = path.sep; - export const renameCollection = (newName, collectionUid) => (dispatch, getState) => { const state = getState(); const collection = findCollectionByUid(state.collections.collections, collectionUid); @@ -186,11 +183,7 @@ export const cancelRequest = (cancelTokenUid, item, collection) => (dispatch) => .catch((err) => console.log(err)); }; -// todo: this can be directly put inside the collections/index.js file -// the coding convention is to put only actions that need ipc in this file -export const sortCollections = (order) => (dispatch) => { - dispatch(_sortCollections(order)); -}; + export const runCollectionFolder = (collectionUid, folderUid, recursive) => (dispatch, getState) => { const state = getState(); const collection = findCollectionByUid(state.collections.collections, collectionUid); @@ -308,19 +301,7 @@ export const renameItem = (newName, itemUid, collectionUid) => (dispatch, getSta } const { ipcRenderer } = window; - ipcRenderer - .invoke('renderer:rename-item', item.pathname, newPathname, newName) - .then(() => { - // In case of Mac and Linux, we get the unlinkDir and addDir IPC events from electron which takes care of updating the state - // But in windows we don't get those events, so we need to update the state manually - // This looks like an issue in our watcher library chokidar - // GH: https://github.com/usebruno/bruno/issues/251 - if (isWindowsOS()) { - dispatch(_renameItem({ newName, itemUid, collectionUid })); - } - resolve(); - }) - .catch(reject); + ipcRenderer.invoke('renderer:rename-item', item.pathname, newPathname, newName).then(resolve).catch(reject); }); }; @@ -405,14 +386,8 @@ export const deleteItem = (itemUid, collectionUid) => (dispatch, getState) => { ipcRenderer .invoke('renderer:delete-item', item.pathname, item.type) .then(() => { - // In case of Mac and Linux, we get the unlinkDir IPC event from electron which takes care of updating the state - // But in windows we don't get those events, so we need to update the state manually - // This looks like an issue in our watcher library chokidar - // GH: https://github.com/usebruno/bruno/issues/265 - if (isWindowsOS()) { - dispatch(_deleteItem({ itemUid, collectionUid })); - } - resolve(); + dispatch(_deleteItem({ itemUid, collectionUid })) + resolve() }) .catch((error) => reject(error)); } @@ -420,6 +395,9 @@ export const deleteItem = (itemUid, collectionUid) => (dispatch, getState) => { }); }; +export const sortCollections = () => (dispatch) => { + dispatch(_sortCollections()) +} export const moveItem = (collectionUid, draggedItemUid, targetItemUid) => (dispatch, getState) => { const state = getState(); const collection = findCollectionByUid(state.collections.collections, collectionUid); diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js index c60b3e68c..4ad30d204 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js @@ -1,4 +1,3 @@ -import path from 'path'; import { uuid } from 'utils/common'; import find from 'lodash/find'; import map from 'lodash/map'; @@ -25,9 +24,7 @@ import { areItemsTheSameExceptSeqUpdate } from 'utils/collections'; import { parseQueryParams, stringifyQueryParams } from 'utils/url'; -import { getSubdirectoriesFromRoot, getDirectoryName } from 'utils/common/platform'; - -const PATH_SEPARATOR = path.sep; +import { getSubdirectoriesFromRoot, getDirectoryName, PATH_SEPARATOR } from 'utils/common/platform'; const initialState = { collections: [], diff --git a/packages/bruno-app/src/utils/common/platform.js b/packages/bruno-app/src/utils/common/platform.js index 771daaf14..03ff9539e 100644 --- a/packages/bruno-app/src/utils/common/platform.js +++ b/packages/bruno-app/src/utils/common/platform.js @@ -48,3 +48,5 @@ export const isMacOS = () => { return osFamily.includes('os x'); }; + +export const PATH_SEPARATOR = isWindowsOS() ? '\\' : '/';