diff --git a/packages/bruno-app/src/components/ResponsePane/index.js b/packages/bruno-app/src/components/ResponsePane/index.js index bf682088..eca996f7 100644 --- a/packages/bruno-app/src/components/ResponsePane/index.js +++ b/packages/bruno-app/src/components/ResponsePane/index.js @@ -17,7 +17,7 @@ const ResponsePane = ({ rightPaneWidth, item, collection }) => { const dispatch = useDispatch(); const tabs = useSelector((state) => state.tabs.tabs); const activeTabUid = useSelector((state) => state.tabs.activeTabUid); - const isLoading = item.response && item.response.state === 'sending'; + const isLoading = ['queued', 'sending'].includes(item.requestState); const selectTab = (tab) => { dispatch( diff --git a/packages/bruno-app/src/providers/App/useCollectionTreeSync.js b/packages/bruno-app/src/providers/App/useCollectionTreeSync.js index 7fecf577..17518351 100644 --- a/packages/bruno-app/src/providers/App/useCollectionTreeSync.js +++ b/packages/bruno-app/src/providers/App/useCollectionTreeSync.js @@ -8,6 +8,7 @@ import { collectionUnlinkDirectoryEvent, collectionUnlinkEnvFileEvent, requestSentEvent, + requestQueuedEvent, scriptEnvironmentUpdateEvent } from 'providers/ReduxStore/slices/collections'; import toast from 'react-hot-toast'; @@ -90,6 +91,10 @@ const useCollectionTreeSync = () => { dispatch(scriptEnvironmentUpdateEvent(val)); }; + const _httpRequestQueued = (val) => { + dispatch(requestQueuedEvent(val)); + }; + ipcRenderer.invoke('renderer:ready'); const removeListener1 = ipcRenderer.on('main:collection-opened', _openCollection); @@ -98,6 +103,7 @@ const useCollectionTreeSync = () => { const removeListener4 = ipcRenderer.on('main:display-error', _displayError); const removeListener5 = ipcRenderer.on('main:http-request-sent', _httpRequestSent); const removeListener6 = ipcRenderer.on('main:script-environment-update', _scriptEnvironmentUpdate); + const removeListener7 = ipcRenderer.on('main:http-request-queued', _httpRequestQueued); return () => { removeListener1(); @@ -106,6 +112,7 @@ const useCollectionTreeSync = () => { removeListener4(); removeListener5(); removeListener6(); + removeListener7(); }; }, [isElectron]); }; 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 3ba45ab2..a8d3c025 100644 --- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js +++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js @@ -157,7 +157,19 @@ export const collectionsSlice = createSlice({ if (item) { item.requestSent = requestSent item.response = item.response || {}; - item.response.state = 'sending'; + item.requestState = 'sending'; + item.cancelTokenUid = cancelTokenUid; + } + } + }, + requestQueuedEvent: (state, action) => { + const { itemUid, collectionUid, cancelTokenUid } = action.payload; + const collection = findCollectionByUid(state.collections, collectionUid); + + if (collection) { + const item = findItemInCollection(collection, itemUid); + if (item) { + item.requestState = 'queued'; item.cancelTokenUid = cancelTokenUid; } } @@ -199,6 +211,7 @@ export const collectionsSlice = createSlice({ if (collection) { const item = findItemInCollection(collection, action.payload.itemUid); if (item) { + item.requestState = 'received'; item.response = action.payload.response; item.cancelTokenUid = null; } @@ -816,6 +829,7 @@ export const { renameItem, cloneItem, requestSentEvent, + requestQueuedEvent, scriptEnvironmentUpdateEvent, requestCancelled, responseReceived, diff --git a/packages/bruno-electron/src/ipc/network/index.js b/packages/bruno-electron/src/ipc/network/index.js index 3ccc4560..b031e053 100644 --- a/packages/bruno-electron/src/ipc/network/index.js +++ b/packages/bruno-electron/src/ipc/network/index.js @@ -52,6 +52,12 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => { const cancelTokenUid = uuid(); try { + mainWindow.webContents.send('main:http-request-queued', { + collectionUid, + itemUid: item.uid, + cancelTokenUid + }); + const _request = item.draft ? item.draft.request : item.request; const request = prepareRequest(_request);