Show if partner is online
This commit is contained in:

committed by
Sebastian Serth

parent
97764bd02e
commit
056a8e5107
@@ -23,13 +23,24 @@ $(document).on('turbolinks:load', function () {
|
||||
|
||||
received(data) {
|
||||
// Called when there's incoming data on the websocket for this channel
|
||||
if (current_user_id !== data['current_user_id']) {
|
||||
CodeOceanEditor.applyChanges(data['delta']['data'], data['active_file']);
|
||||
if (current_user_id !== data.current_user_id) {
|
||||
switch(data.command) {
|
||||
case 'editor_change':
|
||||
CodeOceanEditor.applyChanges(data.delta.data, data.active_file);
|
||||
break;
|
||||
case 'connection_change':
|
||||
CodeOceanEditor.showPartnersConnectionStatus(data.status, data.current_user_name);
|
||||
this.perform('send_hello');
|
||||
break;
|
||||
case 'hello':
|
||||
CodeOceanEditor.showPartnersConnectionStatus(data.status, data.current_user_name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
send_changes(delta, active_file) {
|
||||
const delta_with_user_id = {current_user_id: current_user_id, active_file: active_file, delta: delta}
|
||||
const delta_with_user_id = {command: 'editor_change', current_user_id: current_user_id, active_file: active_file, delta: delta}
|
||||
this.perform('send_changes', {delta_with_user_id: delta_with_user_id});
|
||||
}
|
||||
});
|
||||
|
@@ -1044,6 +1044,17 @@ var CodeOceanEditor = {
|
||||
delta_data.text === last_delta.text;
|
||||
},
|
||||
|
||||
showPartnersConnectionStatus: function (status, username) {
|
||||
switch(status) {
|
||||
case 'connected':
|
||||
$('#pg_session').text(I18n.t('exercises.editor.is_online', {name: username}));
|
||||
break;
|
||||
case 'disconnected':
|
||||
$('#pg_session').text(I18n.t('exercises.editor.is_offline', {name: username}));
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
initializeEverything: function () {
|
||||
CodeOceanEditor.editors = [];
|
||||
this.initializeRegexes();
|
||||
|
@@ -3,7 +3,7 @@ CodeOceanEditorSubmissions = {
|
||||
|
||||
AUTOSAVE_INTERVAL: 15 * 1000,
|
||||
autosaveTimer: null,
|
||||
autosaveLabel: "#statusbar span",
|
||||
autosaveLabel: "#statusbar #autosave",
|
||||
|
||||
/**
|
||||
* Submission-Creation
|
||||
|
Reference in New Issue
Block a user