Synchronize resetCode for pair programming
This commit is contained in:

committed by
Sebastian Serth

parent
cc90861bd5
commit
f37ba34389
@ -63,6 +63,7 @@ $(document).on('turbolinks:load', function () {
|
||||
}
|
||||
break;
|
||||
case 'current_content':
|
||||
case 'reset_content':
|
||||
if (is_other_session(data.session_id)) {
|
||||
CodeOceanEditor.setEditorContent(data);
|
||||
}
|
||||
@ -70,6 +71,10 @@ $(document).on('turbolinks:load', function () {
|
||||
}
|
||||
},
|
||||
|
||||
reset_content(content) {
|
||||
this.perform('reset_content', content);
|
||||
},
|
||||
|
||||
editor_change(delta, active_file) {
|
||||
const message = {session_id: session_id, active_file: active_file, delta: delta}
|
||||
this.perform('editor_change', message);
|
||||
|
@ -119,6 +119,7 @@ CodeOceanEditorSubmissions = {
|
||||
url: $('#start-over').data('url') || $('#start-over-active-file').data('url')
|
||||
}).done(function(response) {
|
||||
this.hideSpinner();
|
||||
App.synchronized_editor?.reset_content(response);
|
||||
this.setEditorContent(response, onlyActiveFile);
|
||||
}.bind(this));
|
||||
},
|
||||
|
@ -46,6 +46,11 @@ class SynchronizedEditorChannel < ApplicationCable::Channel
|
||||
ActionCable.server.broadcast(specific_channel, message)
|
||||
end
|
||||
|
||||
def reset_content(content)
|
||||
message = create_reset_content_message(content)
|
||||
ActionCable.server.broadcast(specific_channel, message)
|
||||
end
|
||||
|
||||
def create_message(action, status)
|
||||
{
|
||||
action:,
|
||||
@ -54,4 +59,13 @@ class SynchronizedEditorChannel < ApplicationCable::Channel
|
||||
session_id: @session_id,
|
||||
}
|
||||
end
|
||||
|
||||
def create_reset_content_message(content)
|
||||
{
|
||||
action: content['action'],
|
||||
files: content['files'],
|
||||
user: current_user.to_page_context,
|
||||
session_id: @session_id,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user