Skip to content

Commit

Permalink
feat(connectionError): display connection error inside Editor
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisDommer committed Dec 12, 2023
1 parent 688609c commit 443cf30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion WebSocketClient/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite dev && dark_mode_dev_env.sh",
"dev": "./dark_mode_dev_env.sh && vite dev",
"build": "tsc && vite build",
"preview": "vite preview"
},
Expand Down
10 changes: 8 additions & 2 deletions WebSocketClient/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ const createWebSocket = (url: string): WebSocket => {
const webSocket = new WebSocket(url);
webSocket.onerror = () => {
if(connectionText){
connectionText.textContent = "Could not connect to language server. Reconnecting ...";
displayEditorError( "Could not connect to language server. Reconnecting ...");
}
setTimeout(() => {
createWebSocket(url);
}, 1000);
};
webSocket.onopen = async () => {
if(connectionText){
connectionText.textContent = "";
displayEditorError("");
}
const socket = toSocket(webSocket);
const reader = new WebSocketMessageReader(socket);
Expand Down Expand Up @@ -308,6 +308,8 @@ export const startPythonClient = async () => {

let globalEditor: IStandaloneCodeEditor | null;


let currentWidget: IOverlayWidget | null;
function displayEditorError(msg: string) {
if(!globalEditor){
return;
Expand All @@ -330,6 +332,10 @@ function displayEditorError(msg: string) {
return node;
}
}
if(currentWidget){
globalEditor.removeOverlayWidget(currentWidget);
}
currentWidget = overlayWidget;
globalEditor.addOverlayWidget(overlayWidget);
// setTimeout(() => {
// if(!globalEditor) return;
Expand Down

0 comments on commit 443cf30

Please sign in to comment.