Unsubscribe from channel when redirecting
fixes CODEOCEAN-FRONTEND-2S
This commit is contained in:

committed by
Sebastian Serth

parent
23a95d315d
commit
0e4a239960
@ -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
|
||||
|
@ -204,6 +204,7 @@ CodeOceanEditorSubmissions = {
|
||||
this.teardownEventHandlers();
|
||||
this.createSubmission(button, null, function (response) {
|
||||
if (response.redirect) {
|
||||
App.synchronized_editor?.unsubscribe();
|
||||
this.autosaveIfChanged();
|
||||
this.stopCode(event);
|
||||
this.editors = [];
|
||||
|
Reference in New Issue
Block a user