From 725460176aaf57fa32414637ff89164de21351ed Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sat, 1 Mar 2014 17:01:45 -0600 Subject: [PATCH] * VRFS-792 - also guard against direct session link joins with no ftue --- web/app/assets/javascripts/fakeJamClient.js | 2 +- web/app/assets/javascripts/ftue.js | 35 +++++++++-- web/app/assets/javascripts/jam_rest.js | 2 - web/app/assets/javascripts/session.js | 65 +++++++++++++-------- web/app/assets/javascripts/sessionModel.js | 39 ------------- web/app/assets/javascripts/sidebar.js | 39 +++++++------ 6 files changed, 92 insertions(+), 90 deletions(-) diff --git a/web/app/assets/javascripts/fakeJamClient.js b/web/app/assets/javascripts/fakeJamClient.js index 682aa8fc0..0039b4acf 100644 --- a/web/app/assets/javascripts/fakeJamClient.js +++ b/web/app/assets/javascripts/fakeJamClient.js @@ -137,7 +137,7 @@ } function FTUEGetGoodConfigurationList() { - return ['a'] + return ['a']; } function RegisterVolChangeCallBack(functionName) { diff --git a/web/app/assets/javascripts/ftue.js b/web/app/assets/javascripts/ftue.js index 7366f251f..d090b7f91 100644 --- a/web/app/assets/javascripts/ftue.js +++ b/web/app/assets/javascripts/ftue.js @@ -17,6 +17,9 @@ var logger = context.JK.logger; var jamClient = context.jamClient; var win32 = true; + var batchModify = false; + var pendingFtueSave = false; + var successfulFtue = false; // tracks in the loopback FTUe what the currently chosen audio driver is var currentAudioDriverId = null; @@ -53,9 +56,17 @@ function afterHide(data) { // Unsubscribe from FTUE VU callbacks. jamClient.FTUERegisterVUCallbacks('', '', ''); + + if(!successfulFtue && app.cancelFtue) { + app.cancelFtue(); + app.afterFtue = null; + app.cancelFtue = null; + } + } function beforeShow(data) { + successfulFtue = false; var vuMeters = [ '#ftue-2-audio-input-vu-left', '#ftue-2-audio-input-vu-right', @@ -543,16 +554,19 @@ setDefaultInstrumentFromProfile(); + logger.debug("Calling FTUESave(" + true + ")"); jamClient.FTUESave(true); jamClient.FTUESetStatus(true); // No FTUE wizard next time rest.userCertifiedGear({success: true}); // notify anyone curious about how it went $('div[layout-id=ftue]').trigger('ftue_success'); + successfulFtue = true; // important to before closeDialog app.layout.closeDialog('ftue'); if (app.afterFtue) { // If there's a function to invoke, invoke it. app.afterFtue(); app.afterFtue = null; + app.cancelFtue = null; } return false; } @@ -630,15 +644,21 @@ // this is necesasry because if you do a FTUE pass, close the client, and pick the same device // the backend will *silently* use values from before, because the frontend does not query the backend // for these values anywhere. + + // setting all 3 of these cause 3 FTUE's. Instead, we set batchModify to true so that they don't call FtueSave(false), and call later ourselves + batchModify = true; newFtueAsioFrameSizeToBackend($('#ftue-2-asio-framesize')); newFtueAsioInputLatencyToBackend($('#ftue-2-asio-input-latency')); newFtueAsioOutputLatencyToBackend($('#ftue-2-asio-output-latency')); + batchModify = false; //setLevels(0); renderVolumes(); + logger.debug("Calling FTUESave(" + false + ")"); + jamClient.FTUESave(false) + pendingFtueSave = false; // this is not really used in any real fashion. just setting back to false due to batch modify above - jamClient.FTUESave(false); setVuCallbacks(); var latency = jamClient.FTUEGetExpectedLatency(); @@ -647,7 +667,9 @@ } function newFtueSave(persist) { + console.log("newFtueSave persist(" +persist+ ")") newFtueUpdateLatencyView('loading'); + logger.debug("Calling FTUESave(" + persist + ")"); jamClient.FTUESave(persist); var latency = jamClient.FTUEGetExpectedLatency(); newFtueUpdateLatencyView(latency); @@ -703,7 +725,7 @@ renderStopNewFtueLatencyTesting(); return; } - newFtueSave(false); + if (batchModify) { pendingFtueSave = true; } else { newFtueSave(false); } }); } @@ -715,7 +737,7 @@ renderStopNewFtueLatencyTesting(); return; } - newFtueSave(false); + if (batchModify) { pendingFtueSave = true; } else { newFtueSave(false); } }); } @@ -727,7 +749,7 @@ renderStopNewFtueLatencyTesting(); return; } - newFtueSave(false); + if (batchModify) { pendingFtueSave = true; } else { newFtueSave(false); } }); } @@ -778,6 +800,11 @@ $bout.val('0'); } + // you need to give these to the backend now; if you don't, when the device is selected, the backend + // may fail to open it (especially with kernel streaming). Causes scary looking errors to user. + newFtueAsioFrameSizeToBackend($('#ftue-2-asio-framesize')); + newFtueAsioInputLatencyToBackend($('#ftue-2-asio-input-latency')); + newFtueAsioOutputLatencyToBackend($('#ftue-2-asio-output-latency')); } function resetFtueLatencyView() { diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js index 4a8a3b564..0a5bea9cd 100644 --- a/web/app/assets/javascripts/jam_rest.js +++ b/web/app/assets/javascripts/jam_rest.js @@ -215,7 +215,6 @@ type: "GET", dataType: "json", url: url, - async: false, processData: false }); } @@ -241,7 +240,6 @@ type: "GET", dataType: "json", url: url, - async: true, processData: false }); } diff --git a/web/app/assets/javascripts/session.js b/web/app/assets/javascripts/session.js index 925c8506e..72380017f 100644 --- a/web/app/assets/javascripts/session.js +++ b/web/app/assets/javascripts/session.js @@ -229,30 +229,41 @@ } } + function initializeSession() { + // indicate that the screen is active, so that + // body-scoped drag handlers can go active + screenActive = true; + + // Subscribe for callbacks on audio events + context.jamClient.SessionRegisterCallback("JK.HandleBridgeCallback"); + context.jamClient.RegisterRecordingCallbacks("JK.HandleRecordingStartResult", "JK.HandleRecordingStopResult", "JK.HandleRecordingStarted", "JK.HandleRecordingStopped", "JK.HandleRecordingAborted"); + context.jamClient.SessionSetAlertCallback("JK.AlertCallback"); + context.jamClient.SessionSetConnectionStatusRefreshRate(1000); + + // If you load this page directly, the loading of the current user + // is happening in parallel. We can't join the session until the + // current user has been completely loaded. Poll for the current user + // before proceeding with session joining. + function checkForCurrentUser() { + if (context.JK.userMe) { + afterCurrentUserLoaded(); + } else { + context.setTimeout(checkForCurrentUser, 100); + } + } + checkForCurrentUser(); + } + function afterShow(data) { - // indicate that the screen is active, so that - // body-scoped drag handlers can go active - screenActive = true; - - // Subscribe for callbacks on audio events - context.jamClient.SessionRegisterCallback("JK.HandleBridgeCallback"); - context.jamClient.RegisterRecordingCallbacks("JK.HandleRecordingStartResult", "JK.HandleRecordingStopResult", "JK.HandleRecordingStarted", "JK.HandleRecordingStopped", "JK.HandleRecordingAborted"); - context.jamClient.SessionSetAlertCallback("JK.AlertCallback"); - context.jamClient.SessionSetConnectionStatusRefreshRate(1000); - - // If you load this page directly, the loading of the current user - // is happening in parallel. We can't join the session until the - // current user has been completely loaded. Poll for the current user - // before proceeding with session joining. - function checkForCurrentUser() { - if (context.JK.userMe) { - afterCurrentUserLoaded(); - } else { - context.setTimeout(checkForCurrentUser, 100); - } + if (!(context.JK.hasOneConfiguredDevice())) { + app.afterFtue = function() { initializeSession(); }; + app.cancelFtue = function() { promptLeave = false; window.location = '/client#/home' }; + app.layout.startNewFtue(); + } + else { + initializeSession(); } - checkForCurrentUser(); } function notifyWithUserInfo(title , text, clientId) { @@ -431,7 +442,7 @@ { no_cancel: true }); } else { - app.ajaxError(xhr, textStatus, errorMessage); + app.notifyServerError(xhr, 'Unable to Join Session'); } }); } @@ -450,9 +461,13 @@ } function beforeHide(data) { - screenActive = false; - sessionModel.leaveCurrentSession() - .fail(app.ajaxError); + + if(screenActive) { + // this path is possible if FTUE is invoked on session page, and they cancel + sessionModel.leaveCurrentSession() + .fail(app.ajaxError); + } + screenActive = false; } function handleTransitionsInRecordingPlayback() { diff --git a/web/app/assets/javascripts/sessionModel.js b/web/app/assets/javascripts/sessionModel.js index 2306dcee4..f4db36576 100644 --- a/web/app/assets/javascripts/sessionModel.js +++ b/web/app/assets/javascripts/sessionModel.js @@ -289,43 +289,6 @@ return foundParticipant; } - function addTrack(sessionId, data) { - logger.debug("updating tracks on the server %o", data); - var url = "/api/sessions/" + sessionId + "/tracks"; - $.ajax({ - type: "POST", - dataType: "json", - contentType: 'application/json', - url: url, - async: false, - data: JSON.stringify(data), - processData:false, - success: function(response) { - // save to the backend - logger.debug("successfully updated tracks on the server"); - //refreshCurrentSession(); - }, - error: function(jqXHR) { app.notifyServerError(jqXHR, "Unable to refresh session data") } - }); - } - - function updateTrack(sessionId, trackId, data) { - var url = "/api/sessions/" + sessionId + "/tracks/" + trackId; - $.ajax({ - type: "POST", - dataType: "json", - contentType: 'application/json', - url: url, - async: false, - data: JSON.stringify(data), - processData:false, - success: function(response) { - logger.debug("Successfully updated track info (" + JSON.stringify(data) + ")"); - }, - error: function(jqXHR) { app.notifyServerError(jqXHR, "Unable to refresh session data") } - }); - } - function deleteTrack(sessionId, trackId) { if (trackId) { @@ -481,8 +444,6 @@ this.subscribe = subscribe; this.participantForClientId = participantForClientId; this.isPlayingRecording = isPlayingRecording; - this.addTrack = addTrack; - this.updateTrack = updateTrack; this.deleteTrack = deleteTrack; this.onWebsocketDisconnected = onWebsocketDisconnected; this.recordingModel = recordingModel; diff --git a/web/app/assets/javascripts/sidebar.js b/web/app/assets/javascripts/sidebar.js index 596425a9b..7fd37acce 100644 --- a/web/app/assets/javascripts/sidebar.js +++ b/web/app/assets/javascripts/sidebar.js @@ -560,27 +560,28 @@ $.each(response.participants, function(index, val) { participants.push({"photo_url": context.JK.resolveAvatarUrl(val.user.photo_url), "name": val.user.name}); }); + + var participantHtml = "You have been invited to join a session with:

"; + participantHtml += ""; + + $.each(participants, function(index, val) { + if (index < 4) { + participantHtml += ""; + } + }); + + participantHtml += "
" + val.name + "
"; + + app.notify({ + "title": "Session Invitation", + "text": participantHtml + }, { + "ok_text": "JOIN SESSION", + "ok_callback": openTerms, + "ok_callback_args": { "session_id": payload.session_id, "notification_id": payload.notification_id } + }); }).error(app.ajaxError); - var participantHtml = "You have been invited to join a session with:

"; - participantHtml += ""; - - $.each(participants, function(index, val) { - if (index < 4) { - participantHtml += ""; - } - }); - - participantHtml += "
" + val.name + "
"; - - app.notify({ - "title": "Session Invitation", - "text": participantHtml - }, { - "ok_text": "JOIN SESSION", - "ok_callback": openTerms, - "ok_callback_args": { "session_id": payload.session_id, "notification_id": payload.notification_id } - }); }); }