mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-27 14:44:07 +00:00
chore: cleanup
This commit is contained in:
@@ -51,13 +51,6 @@ const SingleWSMessage = ({
|
||||
);
|
||||
};
|
||||
|
||||
const onSend = async () => {
|
||||
try {
|
||||
await sendWsRequest(item, collection.uid, content);
|
||||
} catch (error) {
|
||||
console.error('Error sending message:', error);
|
||||
}
|
||||
};
|
||||
const onSave = () => dispatch(saveRequest(item.uid, collection.uid));
|
||||
|
||||
const onDeleteMessage = () => {
|
||||
|
||||
@@ -3,14 +3,14 @@ import { IconWebSocket } from 'components/Icons/Grpc';
|
||||
import classnames from "classnames"
|
||||
import SingleLineEditor from 'components/SingleLineEditor/index';
|
||||
import { requestUrlChanged } from 'providers/ReduxStore/slices/collections';
|
||||
import { saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import { wsConnectOnly, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
||||
import { useTheme } from 'providers/Theme';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import toast from 'react-hot-toast';
|
||||
import { useDispatch } from 'react-redux';
|
||||
import { getPropertyFromDraftOrRequest } from 'utils/collections';
|
||||
import { isMacOS } from 'utils/common/platform';
|
||||
import { closeWsConnection, connectWS, isWsConnectionActive } from 'utils/network/index';
|
||||
import { closeWsConnection, isWsConnectionActive } from 'utils/network/index';
|
||||
import StyledWrapper from './StyledWrapper';
|
||||
|
||||
const WsQueryUrl = ({ item, collection, handleRun }) => {
|
||||
@@ -75,7 +75,7 @@ const WsQueryUrl = ({ item, collection, handleRun }) => {
|
||||
|
||||
const handleConnect = (e) => {
|
||||
setIsConnecting(true)
|
||||
connectWS(item, collection, undefined, undefined, {connectOnly:true});
|
||||
dispatch(wsConnectOnly(item, collection.uid));
|
||||
};
|
||||
|
||||
const onSave = (finalValue) => {
|
||||
|
||||
@@ -20,7 +20,7 @@ import {
|
||||
transformRequestToSaveToFilesystem
|
||||
} from 'utils/collections';
|
||||
import { uuid, waitForNextTick } from 'utils/common';
|
||||
import { cancelNetworkRequest, sendGrpcRequest, sendNetworkRequest, sendWsRequest } from 'utils/network/index';
|
||||
import { cancelNetworkRequest, connectWS, sendGrpcRequest, sendNetworkRequest, sendWsRequest } from 'utils/network/index';
|
||||
import { callIpc } from 'utils/common/ipc';
|
||||
|
||||
import {
|
||||
@@ -242,6 +242,39 @@ export const sendCollectionOauth2Request = (collectionUid, itemUid) => (dispatch
|
||||
});
|
||||
};
|
||||
|
||||
export const wsConnectOnly = (item, collectionUid) => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const { globalEnvironments, activeGlobalEnvironmentUid } = state.globalEnvironments;
|
||||
const collection = findCollectionByUid(state.collections.collections, collectionUid);
|
||||
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (!collection) {
|
||||
return reject(new Error('Collection not found'));
|
||||
}
|
||||
|
||||
let collectionCopy = cloneDeep(collection);
|
||||
|
||||
const itemCopy = cloneDeep(item);
|
||||
|
||||
const requestUid = uuid();
|
||||
itemCopy.requestUid = requestUid;
|
||||
|
||||
const globalEnvironmentVariables = getGlobalEnvironmentVariables({
|
||||
globalEnvironments,
|
||||
activeGlobalEnvironmentUid
|
||||
});
|
||||
collectionCopy.globalEnvironmentVariables = globalEnvironmentVariables;
|
||||
|
||||
const environment = findEnvironmentInCollection(collectionCopy, collectionCopy.activeEnvironmentUid);
|
||||
|
||||
connectWS(itemCopy, collectionCopy, environment, collectionCopy.runtimeVariables, { connectOnly:true })
|
||||
.then(resolve)
|
||||
.catch((err) => {
|
||||
toast.error(err.message);
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
export const sendRequest = (item, collectionUid) => (dispatch, getState) => {
|
||||
const state = getState();
|
||||
const { globalEnvironments, activeGlobalEnvironmentUid } = state.globalEnvironments;
|
||||
|
||||
Reference in New Issue
Block a user