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 777a194ab6..ecda958035 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/actions.js @@ -44,6 +44,7 @@ import { parsePathParams, parseQueryParams, splitOnFirst } from 'utils/url/index import { sendCollectionOauth2Request as _sendCollectionOauth2Request } from 'utils/network/index'; import { name } from 'file-loader'; import slash from 'utils/common/slash'; +import { generateUidBasedOnHash } from 'utils/common/index'; export const renameCollection = (newName, collectionUid) => (dispatch, getState) => { const state = getState(); @@ -460,7 +461,7 @@ export const cloneItem = (newName, itemUid, collectionUid) => (dispatch, getStat dispatch( insertTaskIntoQueue({ - uid: uuid(), + uid: generateUidBasedOnHash(fullName), type: 'OPEN_REQUEST', collectionUid, itemPathname: fullName @@ -489,7 +490,7 @@ export const cloneItem = (newName, itemUid, collectionUid) => (dispatch, getStat dispatch( insertTaskIntoQueue({ - uid: uuid(), + uid: generateUidBasedOnHash(fullName), type: 'OPEN_REQUEST', collectionUid, itemPathname: fullName @@ -767,7 +768,7 @@ export const newHttpRequest = (params) => (dispatch, getState) => { // task middleware will track this and open the new request in a new tab once request is created dispatch( insertTaskIntoQueue({ - uid: uuid(), + uid: generateUidBasedOnHash(fullName), type: 'OPEN_REQUEST', collectionUid, itemPathname: fullName @@ -793,7 +794,7 @@ export const newHttpRequest = (params) => (dispatch, getState) => { // task middleware will track this and open the new request in a new tab once request is created dispatch( insertTaskIntoQueue({ - uid: uuid(), + uid: generateUidBasedOnHash(fullName), type: 'OPEN_REQUEST', collectionUid, itemPathname: fullName 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 b7ef2f86e5..d0cfc63341 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js @@ -18,6 +18,7 @@ import { import { parsePathParams, parseQueryParams, splitOnFirst, stringifyQueryParams } from 'utils/url'; import { getDirectoryName, getSubdirectoriesFromRoot, PATH_SEPARATOR } from 'utils/common/platform'; import toast from 'react-hot-toast'; +import { generateUidBasedOnHash } from 'utils/common/index'; const initialState = { collections: [], @@ -228,7 +229,7 @@ export const collectionsSlice = createSlice({ secret: false, enabled: true, type: 'text', - uid: uuid() + uid: generateUidBasedOnHash(`${collection?.pathname}/environments/${key}`) }); } } @@ -1443,9 +1444,10 @@ export const collectionsSlice = createSlice({ for (const directoryName of subDirectories) { let childItem = currentSubItems.find((f) => f.type === 'folder' && f.name === directoryName); if (!childItem) { + let pathname = `${currentPath}${PATH_SEPARATOR}${directoryName}`; childItem = { - uid: uuid(), - pathname: `${currentPath}${PATH_SEPARATOR}${directoryName}`, + uid: generateUidBasedOnHash(pathname), + pathname, name: directoryName, collapsed: true, type: 'folder', @@ -1498,9 +1500,10 @@ export const collectionsSlice = createSlice({ for (const directoryName of subDirectories) { let childItem = currentSubItems.find((f) => f.type === 'folder' && f.name === directoryName); if (!childItem) { + let pathname = `${currentPath}${PATH_SEPARATOR}${directoryName}`; childItem = { - uid: uuid(), - pathname: `${currentPath}${PATH_SEPARATOR}${directoryName}`, + uid: generateUidBasedOnHash(pathname), + pathname, name: directoryName, collapsed: true, type: 'folder', diff --git a/packages/bruno-app/src/utils/common/index.js b/packages/bruno-app/src/utils/common/index.js index 05f1bad2f8..91d46a3b1f 100644 --- a/packages/bruno-app/src/utils/common/index.js +++ b/packages/bruno-app/src/utils/common/index.js @@ -158,3 +158,8 @@ export const humanizeDate = (dateString) => { day: 'numeric' }); }; + +export const generateUidBasedOnHash = (str) => { + const hash = simpleHash(str); + return `${hash}`.padEnd(21, '0'); +}; diff --git a/packages/bruno-electron/src/cache/requestUids.js b/packages/bruno-electron/src/cache/requestUids.js index 55f7fc2917..7f8cc74f5b 100644 --- a/packages/bruno-electron/src/cache/requestUids.js +++ b/packages/bruno-electron/src/cache/requestUids.js @@ -11,13 +11,13 @@ */ const requestUids = new Map(); -const { uuid } = require('../utils/common'); +const { generateUidBasedOnHash } = require('../utils/common'); const getRequestUid = (pathname) => { let uid = requestUids.get(pathname); if (!uid) { - uid = uuid(); + uid = generateUidBasedOnHash(pathname); requestUids.set(pathname, uid); }