mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 14:41:04 +01:00
feat: improved request queuing status functionality
This commit is contained in:
parent
b2c28465e9
commit
050ee2680f
@ -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(
|
||||
|
@ -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]);
|
||||
};
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user