close ws on modals open (#994)

This commit is contained in:
lirazyehezkel
2022-04-12 17:56:03 +03:00
committed by GitHub
parent df1fd2c3a7
commit 81fe4af30d
2 changed files with 14 additions and 10 deletions

View File

@@ -49,14 +49,15 @@ interface TrafficViewerProps {
actionButtons?: JSX.Element,
isShowStatusBar?: boolean,
webSocketUrl: string,
isCloseWebSocket: boolean,
shouldCloseWebSocket: boolean,
setShouldCloseWebSocket: (flag: boolean) => void,
isDemoBannerView: boolean
}
export const TrafficViewer: React.FC<TrafficViewerProps> = ({
setAnalyzeStatus, trafficViewerApiProp,
actionButtons, isShowStatusBar, webSocketUrl,
isCloseWebSocket, isDemoBannerView
shouldCloseWebSocket, setShouldCloseWebSocket, isDemoBannerView
}) => {
const classes = useLayoutStyles();
@@ -104,8 +105,11 @@ export const TrafficViewer: React.FC<TrafficViewerProps> = ({
}, [query, handleQueryChange]);
useEffect(() => {
isCloseWebSocket && closeWebSocket()
}, [isCloseWebSocket])
if(shouldCloseWebSocket){
closeWebSocket()
setShouldCloseWebSocket(false);
}
}, [shouldCloseWebSocket])
useEffect(() => {
reopenConnection()
@@ -295,11 +299,11 @@ const MemoiedTrafficViewer = React.memo(TrafficViewer)
const TrafficViewerContainer: React.FC<TrafficViewerProps> = ({
setAnalyzeStatus, trafficViewerApiProp,
actionButtons, isShowStatusBar = true,
webSocketUrl, isCloseWebSocket, isDemoBannerView
webSocketUrl, shouldCloseWebSocket, setShouldCloseWebSocket, isDemoBannerView
}) => {
return <RecoilRoot>
<MemoiedTrafficViewer actionButtons={actionButtons} isShowStatusBar={isShowStatusBar} webSocketUrl={webSocketUrl}
isCloseWebSocket={isCloseWebSocket} trafficViewerApiProp={trafficViewerApiProp}
shouldCloseWebSocket={shouldCloseWebSocket} setShouldCloseWebSocket={setShouldCloseWebSocket} trafficViewerApiProp={trafficViewerApiProp}
setAnalyzeStatus={setAnalyzeStatus} isDemoBannerView={isDemoBannerView}/>
<ToastContainer enableMultiContainer containerId={TOAST_CONTAINER_ID}
position="bottom-right"