From 8a7a1d21ad2fb0d73b023308b3bea458429b6b6b Mon Sep 17 00:00:00 2001 From: Gandharv Date: Fri, 27 May 2022 14:16:29 +0530 Subject: [PATCH] fix: datasources/dataqueries refresh post-addition (#3140) --- frontend/src/Editor/Editor.jsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/frontend/src/Editor/Editor.jsx b/frontend/src/Editor/Editor.jsx index f143368eb7..b8250c4f01 100644 --- a/frontend/src/Editor/Editor.jsx +++ b/frontend/src/Editor/Editor.jsx @@ -408,8 +408,11 @@ class Editor extends React.Component { this.initComponentVersioning(); }; + /** + * https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState + */ dataSourcesChanged = () => { - if (this.socket instanceof WebSocket) { + if (this.socket instanceof WebSocket && this.socket?.readyState === WebSocket.OPEN) { this.socket?.send( JSON.stringify({ event: 'events', @@ -421,9 +424,12 @@ class Editor extends React.Component { } }; + /** + * https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/readyState + */ dataQueriesChanged = () => { this.setState({ addingQuery: false }, () => { - if (this.socket instanceof WebSocket) { + if (this.socket instanceof WebSocket && this.socket?.readyState === WebSocket.OPEN) { this.socket?.send( JSON.stringify({ event: 'events',