mirror of
https://github.com/usebruno/bruno.git
synced 2024-12-22 23:02:40 +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 dispatch = useDispatch();
|
||||||
const tabs = useSelector((state) => state.tabs.tabs);
|
const tabs = useSelector((state) => state.tabs.tabs);
|
||||||
const activeTabUid = useSelector((state) => state.tabs.activeTabUid);
|
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) => {
|
const selectTab = (tab) => {
|
||||||
dispatch(
|
dispatch(
|
||||||
|
@ -8,6 +8,7 @@ import {
|
|||||||
collectionUnlinkDirectoryEvent,
|
collectionUnlinkDirectoryEvent,
|
||||||
collectionUnlinkEnvFileEvent,
|
collectionUnlinkEnvFileEvent,
|
||||||
requestSentEvent,
|
requestSentEvent,
|
||||||
|
requestQueuedEvent,
|
||||||
scriptEnvironmentUpdateEvent
|
scriptEnvironmentUpdateEvent
|
||||||
} from 'providers/ReduxStore/slices/collections';
|
} from 'providers/ReduxStore/slices/collections';
|
||||||
import toast from 'react-hot-toast';
|
import toast from 'react-hot-toast';
|
||||||
@ -90,6 +91,10 @@ const useCollectionTreeSync = () => {
|
|||||||
dispatch(scriptEnvironmentUpdateEvent(val));
|
dispatch(scriptEnvironmentUpdateEvent(val));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const _httpRequestQueued = (val) => {
|
||||||
|
dispatch(requestQueuedEvent(val));
|
||||||
|
};
|
||||||
|
|
||||||
ipcRenderer.invoke('renderer:ready');
|
ipcRenderer.invoke('renderer:ready');
|
||||||
|
|
||||||
const removeListener1 = ipcRenderer.on('main:collection-opened', _openCollection);
|
const removeListener1 = ipcRenderer.on('main:collection-opened', _openCollection);
|
||||||
@ -98,6 +103,7 @@ const useCollectionTreeSync = () => {
|
|||||||
const removeListener4 = ipcRenderer.on('main:display-error', _displayError);
|
const removeListener4 = ipcRenderer.on('main:display-error', _displayError);
|
||||||
const removeListener5 = ipcRenderer.on('main:http-request-sent', _httpRequestSent);
|
const removeListener5 = ipcRenderer.on('main:http-request-sent', _httpRequestSent);
|
||||||
const removeListener6 = ipcRenderer.on('main:script-environment-update', _scriptEnvironmentUpdate);
|
const removeListener6 = ipcRenderer.on('main:script-environment-update', _scriptEnvironmentUpdate);
|
||||||
|
const removeListener7 = ipcRenderer.on('main:http-request-queued', _httpRequestQueued);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
removeListener1();
|
removeListener1();
|
||||||
@ -106,6 +112,7 @@ const useCollectionTreeSync = () => {
|
|||||||
removeListener4();
|
removeListener4();
|
||||||
removeListener5();
|
removeListener5();
|
||||||
removeListener6();
|
removeListener6();
|
||||||
|
removeListener7();
|
||||||
};
|
};
|
||||||
}, [isElectron]);
|
}, [isElectron]);
|
||||||
};
|
};
|
||||||
|
@ -157,7 +157,19 @@ export const collectionsSlice = createSlice({
|
|||||||
if (item) {
|
if (item) {
|
||||||
item.requestSent = requestSent
|
item.requestSent = requestSent
|
||||||
item.response = item.response || {};
|
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;
|
item.cancelTokenUid = cancelTokenUid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,6 +211,7 @@ export const collectionsSlice = createSlice({
|
|||||||
if (collection) {
|
if (collection) {
|
||||||
const item = findItemInCollection(collection, action.payload.itemUid);
|
const item = findItemInCollection(collection, action.payload.itemUid);
|
||||||
if (item) {
|
if (item) {
|
||||||
|
item.requestState = 'received';
|
||||||
item.response = action.payload.response;
|
item.response = action.payload.response;
|
||||||
item.cancelTokenUid = null;
|
item.cancelTokenUid = null;
|
||||||
}
|
}
|
||||||
@ -816,6 +829,7 @@ export const {
|
|||||||
renameItem,
|
renameItem,
|
||||||
cloneItem,
|
cloneItem,
|
||||||
requestSentEvent,
|
requestSentEvent,
|
||||||
|
requestQueuedEvent,
|
||||||
scriptEnvironmentUpdateEvent,
|
scriptEnvironmentUpdateEvent,
|
||||||
requestCancelled,
|
requestCancelled,
|
||||||
responseReceived,
|
responseReceived,
|
||||||
|
@ -52,6 +52,12 @@ const registerNetworkIpc = (mainWindow, watcher, lastOpenedCollections) => {
|
|||||||
const cancelTokenUid = uuid();
|
const cancelTokenUid = uuid();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
mainWindow.webContents.send('main:http-request-queued', {
|
||||||
|
collectionUid,
|
||||||
|
itemUid: item.uid,
|
||||||
|
cancelTokenUid
|
||||||
|
});
|
||||||
|
|
||||||
const _request = item.draft ? item.draft.request : item.request;
|
const _request = item.draft ? item.draft.request : item.request;
|
||||||
const request = prepareRequest(_request);
|
const request = prepareRequest(_request);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user