Unsubscribe from channel when redirecting

fixes CODEOCEAN-FRONTEND-2S
This commit is contained in:
kiragrammel
2023-09-04 11:09:31 +02:00
committed by Sebastian Serth
parent 23a95d315d
commit 0e4a239960
2 changed files with 4 additions and 0 deletions

View File

@@ -1064,6 +1064,9 @@ var CodeOceanEditor = {
this.initializeDeadlines();
CodeOceanEditorTips.initializeEventHandlers();
window.addEventListener("turbolinks:before-render", App.synchronized_editor?.unsubscribe.bind(App.synchronized_editor));
window.addEventListener("beforeunload", App.synchronized_editor?.unsubscribe.bind(App.synchronized_editor));
window.addEventListener("turbolinks:before-render", this.autosaveIfChanged.bind(this));
window.addEventListener("beforeunload", this.autosaveIfChanged.bind(this));
// create autosave when the editor is opened the first time