From 21af8446ca5c49d7350af850d3ddbf31fc3e7b87 Mon Sep 17 00:00:00 2001 From: Nuwan Date: Sat, 13 Aug 2022 00:33:24 +0530 Subject: [PATCH] async call fixes for audio gear setup --- .../javascripts/accounts_audio_profile.js | 43 +++++++------ web/app/assets/javascripts/asyncJamClient.js | 2 +- web/app/assets/javascripts/configureTrack.js | 44 +++++++------ web/app/assets/javascripts/ftue.js | 4 +- .../ConfigureLiveTracksDialog.js.jsx.coffee | 61 +++++++++++++------ .../ConfigureTracks.js.jsx.coffee | 13 ++-- .../stores/ConfigureTracksStore.js.coffee | 3 +- .../javascripts/wizard/gear/gear_wizard.js | 12 ++-- 8 files changed, 111 insertions(+), 71 deletions(-) diff --git a/web/app/assets/javascripts/accounts_audio_profile.js b/web/app/assets/javascripts/accounts_audio_profile.js index bf91c5d3f..994b7f9a8 100644 --- a/web/app/assets/javascripts/accounts_audio_profile.js +++ b/web/app/assets/javascripts/accounts_audio_profile.js @@ -142,7 +142,7 @@ await context.jamClient.TrackDeleteProfile(audioProfileId); // redraw after deletion of profile - populateAccountAudio(); + await populateAccountAudio(); } async function handleLoopbackAudioProfile(audioProfileId) { @@ -156,7 +156,7 @@ } else { // redraw after activation of profile - populateAccountAudio(); + await populateAccountAudio(); } } @@ -192,11 +192,13 @@ } // redraw after activation of profile - populateAccountAudio(); + await populateAccountAudio(); } app.layout.showDialog('configure-tracks') - .one(EVENTS.DIALOG_CLOSED, populateAccountAudio) + .one(EVENTS.DIALOG_CLOSED, async function(){ + await populateAccountAudio() + }) } async function handleActivateAudioProfile(audioProfileId) { @@ -215,18 +217,18 @@ } // redraw after activation of profile - populateAccountAudio(); + await populateAccountAudio(); } - function handleStartAudioQualification() { + async function handleStartAudioQualification() { - app.afterFtue = function() { + app.afterFtue = async function() { showingGearWizard = false; - if(populateAccountAudio().length == 1) { + if(await populateAccountAudio().length == 1) { app.layout.showDialog('join-test-session'); } }; - app.cancelFtue = function() { showingGearWizard = false; populateAccountAudio() }; + app.cancelFtue = async function() { showingGearWizard = false; await populateAccountAudio() }; showingGearWizard = true; app.layout.startNewFtue() } @@ -235,28 +237,33 @@ // false = don't start audio, true = reload last audio configuration, false = don't re-init tracks await context.jamClient.ReloadAudioSystem(false, true, false); - populateAccountAudio(); + await populateAccountAudio(); } function registerFtueSuccess() { - $('div[layout-id=ftue]').on("ftue_success", ftueSuccessHandler); + $('div[layout-id=ftue]').on("ftue_success", async function(){ + await ftueSuccessHandler() + }); } function unregisterFtueSuccess() { - $('div[layout-id=ftue]').off("ftue_success", ftueSuccessHandler); + $('div[layout-id=ftue]').off("ftue_success", async function(){ + await ftueSuccessHandler(); + }); } - function ftueSuccessHandler() { - populateAccountAudio(); + async function ftueSuccessHandler() { + await populateAccountAudio(); } // events for main screen function events() { // wire up main panel clicks $root = $('#account-audio-content-scroller'); - $root.on('click', 'a[data-purpose=delete-audio-profile]', function (evt) { + $root.on('click', 'a[data-purpose=delete-audio-profile]', async function (evt) { evt.stopPropagation(); - handleDeleteAudioProfile($(this).attr('data-id')); + alert('') + await handleDeleteAudioProfile($(this).attr('data-id')); return false; }); @@ -303,10 +310,10 @@ }); - $root.on('click', 'a[data-purpose=add-profile]', function (evt) { + $root.on('click', 'a[data-purpose=add-profile]', async function (evt) { evt.stopPropagation(); cancelRescan(); - handleStartAudioQualification(); + await handleStartAudioQualification(); return false; }); diff --git a/web/app/assets/javascripts/asyncJamClient.js b/web/app/assets/javascripts/asyncJamClient.js index d445fa292..3abb9c13e 100644 --- a/web/app/assets/javascripts/asyncJamClient.js +++ b/web/app/assets/javascripts/asyncJamClient.js @@ -492,7 +492,7 @@ let method = Object.keys(response)[0] switch (method) { case 'execute_script': - //logger.log(`execute_script: ${response['execute_script']}`); + logger.log(`execute_script: ${response['execute_script']}`); eval(response['execute_script']); break; diff --git a/web/app/assets/javascripts/configureTrack.js b/web/app/assets/javascripts/configureTrack.js index 4709cbc22..7cf9ff685 100644 --- a/web/app/assets/javascripts/configureTrack.js +++ b/web/app/assets/javascripts/configureTrack.js @@ -156,10 +156,14 @@ $('#btn-error-ok').click(context.JK.showOverlay); $('#btn-save-settings').unbind("click"); - $('#btn-save-settings').click(saveSettings); + $('#btn-save-settings').click(async function(){ + await saveSettings() + }); $('#btn-cancel-settings').unbind("click"); - $('#btn-cancel-settings').click(cancelSettings); + $('#btn-cancel-settings').click(async function(){ + await cancelSettings() + }); } function _handleTrackInputAdd($selectedMusicInputs, selector) { @@ -269,7 +273,7 @@ logger.debug("Called TrackSetMusicDevice with " + $('#audio-drivers').val()); await context.jamClient.TrackLoadAssignments(); - initDialogData(); + await initDialogData(); // refresh dialog showVoiceChatPanel(true); @@ -455,36 +459,36 @@ } } - function initDialogData() { - _initMusicTabData(); - _initVoiceChatTabData(); + async function initDialogData() { + await _initMusicTabData(); + await _initVoiceChatTabData(); } - function _initMusicTabData() { - inputUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, true, false); + async function _initMusicTabData() { + inputUnassignedList = await _loadList(ASSIGNMENT.UNASSIGNED, true, false); //logger.debug("inputUnassignedList=" + JSON.stringify(inputUnassignedList)); - track1AudioInputChannels = _loadList(ASSIGNMENT.TRACK1, true, false); + track1AudioInputChannels = await _loadList(ASSIGNMENT.TRACK1, true, false); //logger.debug("track1AudioInputChannels=" + JSON.stringify(track1AudioInputChannels)); - track2AudioInputChannels = _loadList(ASSIGNMENT.TRACK2, true, false); + track2AudioInputChannels = await _loadList(ASSIGNMENT.TRACK2, true, false); //logger.debug("track2AudioInputChannels=" + JSON.stringify(track2AudioInputChannels)); - outputUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, false, false); - outputAssignedList = _loadList(ASSIGNMENT.OUTPUT, false, false); + outputUnassignedList = await _loadList(ASSIGNMENT.UNASSIGNED, false, false); + outputAssignedList = await _loadList(ASSIGNMENT.OUTPUT, false, false); } - function _initVoiceChatTabData() { - chatUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, true, false); + async function _initVoiceChatTabData() { + chatUnassignedList = await _loadList(ASSIGNMENT.UNASSIGNED, true, false); //logger.debug("chatUnassignedList=" + JSON.stringify(chatUnassignedList)); - chatAssignedList = _loadList(ASSIGNMENT.CHAT, true, false); + chatAssignedList = await _loadList(ASSIGNMENT.CHAT, true, false); //logger.debug("chatAssignedList=" + JSON.stringify(chatAssignedList)); - chatOtherUnassignedList = _loadList(ASSIGNMENT.UNASSIGNED, true, true); + chatOtherUnassignedList = await _loadList(ASSIGNMENT.UNASSIGNED, true, true); //logger.debug("chatOtherUnassignedList=" + JSON.stringify(chatOtherUnassignedList)); - chatOtherAssignedList = _loadList(ASSIGNMENT.CHAT, true, true); + chatOtherAssignedList = await _loadList(ASSIGNMENT.CHAT, true, true); //logger.debug("chatOtherAssignedList=" + JSON.stringify(chatOtherAssignedList)); } @@ -552,8 +556,8 @@ return; } - saveAudioSettings(); - saveVoiceChatSettings(); + await saveAudioSettings(); + await saveVoiceChatSettings(); await context.jamClient.TrackSaveAssignments(); @@ -786,7 +790,7 @@ originalDeviceId = await context.jamClient.TrackGetMusicDeviceID(); await context.jamClient.TrackLoadAssignments(); - initDialogData(); + await initDialogData(); var $option1 = $('#voice-chat-type > option[value="1"]'); diff --git a/web/app/assets/javascripts/ftue.js b/web/app/assets/javascripts/ftue.js index c24a76c59..5f1215ee4 100644 --- a/web/app/assets/javascripts/ftue.js +++ b/web/app/assets/javascripts/ftue.js @@ -58,7 +58,7 @@ await jamClient.FTUERegisterVUCallbacks('', '', ''); if (!successfulFtue && app.cancelFtue) { - app.cancelFtue(); + await app.cancelFtue(); app.afterFtue = null; app.cancelFtue = null; } @@ -585,7 +585,7 @@ app.layout.closeDialog('ftue'); if (app.afterFtue) { // If there's a function to invoke, invoke it. - app.afterFtue(); + await app.afterFtue(); app.afterFtue = null; app.cancelFtue = null; } diff --git a/web/app/assets/javascripts/react-components/ConfigureLiveTracksDialog.js.jsx.coffee b/web/app/assets/javascripts/react-components/ConfigureLiveTracksDialog.js.jsx.coffee index f45531854..de6ce4f35 100644 --- a/web/app/assets/javascripts/react-components/ConfigureLiveTracksDialog.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/ConfigureLiveTracksDialog.js.jsx.coffee @@ -110,7 +110,7 @@ ConfigureTracksStore = @ConfigureTracksStore

Instrument

- {this.instrumentSelected()}} value={selectedInstrument} disabled={instrumentDisabled}> {instruments}
@@ -188,7 +188,7 @@ ConfigureTracksStore = @ConfigureTracksStore

Instrument

- { await this.instrumentSelected()}} value={selectedInstrument} disabled={instrumentDisabled}> {instruments}
@@ -286,12 +286,20 @@ ConfigureTracksStore = @ConfigureTracksStore @setState({midiInterface: null}) - instrumentSelected: (e) -> - $root = $(@getDOMNode()) - $select = $root.find('.instrument-pick') + # instrumentSelected: (e) -> + # $root = $(@getDOMNode()) + # $select = $root.find('.instrument-pick') - instrumentId = $select.val() - ConfigureTracksActions.associateInstrumentWithTrack(instrumentId) + # instrumentId = $select.val() + # ConfigureTracksActions.associateInstrumentWithTrack(instrumentId) + + instrumentSelected: `async function(e) { + const $root = $(this.getDOMNode()); + const $select = $root.find('.instrument-pick'); + + const instrumentId = $select.val(); + await ConfigureTracksActions.associateInstrumentWithTrack(instrumentId); + }` doClose: (e) -> @@ -342,20 +350,39 @@ ConfigureTracksStore = @ConfigureTracksStore componentWillUpdate: () -> $root = $(@getDOMNode()) - componentDidUpdate: () -> - $root = $(@getDOMNode()) + # componentDidUpdate: () -> + # $root = $(@getDOMNode()) - $manageAudioPlugins = $root.find('.manage-audio-plugins') + # $manageAudioPlugins = $root.find('.manage-audio-plugins') - unless $manageAudioPlugins.data('initialized') - $manageAudioPlugins.manageVsts().on(context.JK.EVENTS.VST_OPERATION_SELECTED, @vstOperation).data('initialized', true) + # unless $manageAudioPlugins.data('initialized') + # $manageAudioPlugins.manageVsts().on(context.JK.EVENTS.VST_OPERATION_SELECTED, @vstOperation).data('initialized', true) - if true # easyDropdown support + # if true # easyDropdown support + + # context.JK.dropdown($root.find('select')) + # $root.find('select.input-selectors').unbind('change').change(@inputChanged) + # $root.find('select.instrument-pick').unbind('change').change(@instrumentSelected) + # $root.find('select.vsts').unbind('change').change(@vstsChanged) + + componentDidUpdate: `async function() { + const $root = $(this.getDOMNode()); + + const $manageAudioPlugins = $root.find('.manage-audio-plugins'); + + if (!$manageAudioPlugins.data('initialized')) { + $manageAudioPlugins.manageVsts().on(context.JK.EVENTS.VST_OPERATION_SELECTED, this.vstOperation).data('initialized', true); + } + + if (true) { // easyDropdown support + + context.JK.dropdown($root.find('select')); + $root.find('select.input-selectors').unbind('change').change(this.inputChanged); + $root.find('select.instrument-pick').unbind('change').change(this.instrumentSelected); + return $root.find('select.vsts').unbind('change').change(this.vstsChanged); + } + }` - context.JK.dropdown($root.find('select')) - $root.find('select.input-selectors').unbind('change').change(@inputChanged) - $root.find('select.instrument-pick').unbind('change').change(@instrumentSelected) - $root.find('select.vsts').unbind('change').change(@vstsChanged) trackTypeChanged: (event) -> if @ignoreICheck diff --git a/web/app/assets/javascripts/react-components/ConfigureTracks.js.jsx.coffee b/web/app/assets/javascripts/react-components/ConfigureTracks.js.jsx.coffee index f23f1fb57..6b72e1e44 100644 --- a/web/app/assets/javascripts/react-components/ConfigureTracks.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/ConfigureTracks.js.jsx.coffee @@ -25,15 +25,15 @@ MIDI_TRACK = context.JK.MIDI_TRACK outputs = [] trackAssignments = @state.configureTracks?.trackAssignments - + if gon.midi_enabled addMidiTrack = `ADD MIDI TRACK . . . ` if trackAssignments - + #console.log("trackAssignments.inputs.assigned", trackAssignments.inputs.assigned) for inputsForTrack, i in trackAssignments.inputs.assigned candidate = inputsForTrack[0] - + inputs = [] if candidate.assignment == MIDI_TRACK trackTypeLabel = 'MIDI' @@ -46,14 +46,13 @@ MIDI_TRACK = context.JK.MIDI_TRACK trackTypeLabel = 'AUDIO' for input in inputsForTrack inputs.push(`
{input.name}
`) - + if !inputsForTrack.instrument_id? + instrument = `?` else instrument = `` - - - + vstName = 'None' if inputsForTrack.vst? && inputsForTrack.vst.name != 'NONE' diff --git a/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee b/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee index 0cce51904..8dc74f09b 100644 --- a/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee +++ b/web/app/assets/javascripts/react-components/stores/ConfigureTracksStore.js.coffee @@ -607,6 +607,7 @@ void removeSearchPath(int typeId, QString pathToRemove); # context.JK.Banner.showAlert('Unable to save assignments. ' + result); onAssociateInstrumentWithTrack: `async function(instrumentId) { + if (this.trackNumber == null) { return; } logger.debug("context.jamClient.TrackSetInstrument(trackNumber, track.instrument_id)", this.trackNumber, instrumentId); @@ -619,7 +620,7 @@ void removeSearchPath(int typeId, QString pathToRemove); } await context.jamClient.TrackSetInstrument(this.trackNumber, clientInstrumentId); - + if (this.trackNumber === MIDI_TRACK) { logger.debug("checking midi track for track instrument synchronization"); // keep artificial midi track in sync diff --git a/web/app/assets/javascripts/wizard/gear/gear_wizard.js b/web/app/assets/javascripts/wizard/gear/gear_wizard.js index 3af6b5960..8144da861 100644 --- a/web/app/assets/javascripts/wizard/gear/gear_wizard.js +++ b/web/app/assets/javascripts/wizard/gear/gear_wizard.js @@ -139,11 +139,11 @@ } } - function onCanceled() { + async function onCanceled() { reportFailureAnalytics(); if (app.cancelFtue) { - app.cancelFtue(); + await app.cancelFtue(); app.afterFtue = null; app.cancelFtue = null; } @@ -151,12 +151,12 @@ return closeDialog(); } - function onClosed() { + async function onClosed() { reportFailureAnalytics(); if (app.afterFtue) { // If there's a function to invoke, invoke it. - app.afterFtue(); + await app.afterFtue(); app.afterFtue = null; app.cancelFtue = null; } @@ -173,7 +173,9 @@ function events() { $(wizard).on('step_changed', onStepChanged); $(wizard).on('wizard_cancel', onCanceled); - $(wizard).on('wizard_close', onClosed); + $(wizard).on('wizard_close', async function(){ + await onClosed() + }); } function setNextState(enabled) {