aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakob.stendahl <jakob.stendahl@infomedia.dk>2022-12-05 10:11:01 +0100
committerJakob Stendahl <jakob.stendahl@outlook.com>2022-12-05 10:11:01 +0100
commit7beca23767641c8e52d22109069909f6380cb99b (patch)
tree9ce32d4f9763c96e70660fb004c36ed6e5db216e
parentf11e1fa3ee69bc117f38430de0f4c3543894424c (diff)
downloadLuxcena-Neo-7beca23767641c8e52d22109069909f6380cb99b.tar.gz
Luxcena-Neo-7beca23767641c8e52d22109069909f6380cb99b.zip
Save before some changes
-rw-r--r--src_frontend/Components/Editor/Editor.svelte77
1 files changed, 56 insertions, 21 deletions
diff --git a/src_frontend/Components/Editor/Editor.svelte b/src_frontend/Components/Editor/Editor.svelte
index 70d5478..36390ce 100644
--- a/src_frontend/Components/Editor/Editor.svelte
+++ b/src_frontend/Components/Editor/Editor.svelte
@@ -33,6 +33,7 @@
function initDebugger() {
if (debuggerInitialised) { return; }
+ addSocketListeners();
debuggerInitialised = true;
console.log("emitting editor:open");
authorizedSocket.emit("editor:open", `user/${modeId}`, (res) => {
@@ -40,6 +41,51 @@
});
}
+ function addSocketListeners() {
+ authorizedSocket.on("editor:proc:start", onEditorProcStart);
+ authorizedSocket.on("editor:proc:exit", onEditorProcExit);
+ authorizedSocket.on("editor:debugger:state", onEditorDebuggerState);
+ authorizedSocket.on("editor:code", createCodeEditor);
+ console.log("Attempted to add listeners");
+ }
+
+ function removeSocketListeners() {
+ authorizedSocket.off("editor:proc:start", onEditorProcStart);
+ authorizedSocket.off("editor:proc:exit", onEditorProcExit);
+ authorizedSocket.off("editor:debugger:state", onEditorDebuggerState);
+ authorizedSocket.off("editor:code", createCodeEditor);
+ //authorizedSocket.removeAllListeners("editor:proc:start");
+ //authorizedSocket.removeAllListeners("editor:proc:exit");
+ //authorizedSocket.removeAllListeners("editor:debugger:state");
+ //authorizedSocket.removeAllListeners("editor:code");
+ console.log("Listeners attempted removed");
+ }
+
+ function closeDebugger() {
+ saveCode((res) => {
+ handleError(res);
+ console.log("emitting editor:close");
+ authorizedSocket.emit("editor:close", res => {
+ handleError(res);
+ debuggerInitialised = false;
+ });
+ });
+ }
+
+ function onEditorProcStart() {
+ console.log("received editor:proc:start");
+ procIsRunning = true
+ }
+
+ function onEditorProcExit(code) {
+ console.log("received editor:proc:exit");
+ procIsRunning = false;
+ }
+
+ function onEditorDebuggerState(state) {
+ console.log(state);
+ }
+
function notifErr(err) {
if (err.hasOwnProperty("detail")) {
notif({title: err.reason, type: "danger"});
@@ -69,8 +115,9 @@
}
}
- authorizedSocket.on("editor:code", (modeId, code) => {
+ function createCodeEditor(modeId, code) {
console.log("received editor:code");
+ console.log(code);
const chalky = "#e5c07b",
coral = "#e06c75",
cyan = "#56b6c2",
@@ -87,6 +134,7 @@
selection = "#3E4451",
cursor = "#528bff"
+ console.log(codeEditorEl);
codeEditorView = new EditorView({
state: EditorState.create({
extensions: [
@@ -199,15 +247,7 @@
}),
parent: codeEditorEl
})
- });
- authorizedSocket.on("editor:proc:start", () => {
- console.log("received editor:proc:start");
- procIsRunning = true
- });
- authorizedSocket.on("editor:proc:exit", (code) => {
- console.log("received editor:proc:exit");
- procIsRunning = false;
- });
+ }
function startProc() {
saveCode((res) => {
@@ -258,18 +298,8 @@
codeEditorHasChanges = false;
}
- function closeDebugger() {
- saveCode((res) => {
- handleError(res);
- console.log("emitting editor:close");
- authorizedSocket.emit("editor:close", res => {
- handleError(res);
- debuggerInitialised = false;
- });
- });
- }
-
onMount(() => {
+ console.log("onMount");
codeEditorHasChanges = false;
procIsRunning = false;
failCount = 0;
@@ -278,6 +308,11 @@
});
onDestroy(() => {
+ console.log("onDestroy");
+ if (debuggerInitialised) {
+ debuggerInitialised = false;
+ removeSocketListeners();
+ }
if (get(openSocketConnected)) {
closeDebugger();
} else {