From 98aa2adc4214e5c57242f73620beddfcb94eddbf Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 14 Aug 2022 17:00:38 -0500 Subject: [PATCH] Remove 2 context._.each statements combined with async --- web/app/assets/javascripts/asyncJamClient.js | 2 +- .../javascripts/wizard/gear/gear_wizard.js | 4 ++-- .../wizard/gear/step_select_gear.js | 5 ++-- .../assets/javascripts/wizard/gear_utils.js | 23 +++++++++++-------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/web/app/assets/javascripts/asyncJamClient.js b/web/app/assets/javascripts/asyncJamClient.js index 3abb9c13e..fff69e602 100644 --- a/web/app/assets/javascripts/asyncJamClient.js +++ b/web/app/assets/javascripts/asyncJamClient.js @@ -611,4 +611,4 @@ setupWebSocketConnection(); return setupAsyncProxy(); }; -})(window, jQuery); \ No newline at end of file +})(window, jQuery); diff --git a/web/app/assets/javascripts/wizard/gear/gear_wizard.js b/web/app/assets/javascripts/wizard/gear/gear_wizard.js index 8144da861..758ce5586 100644 --- a/web/app/assets/javascripts/wizard/gear/gear_wizard.js +++ b/web/app/assets/javascripts/wizard/gear/gear_wizard.js @@ -47,11 +47,11 @@ async function newSession() { inputs = null; - context._.each(STEPS, async function(stepInfo, stepNumber) { + for(const [stepInfo, stepNumber] of Object.entries(STEPS)) { if(stepInfo.newSession) { await stepInfo.newSession.call(stepInfo); } - }); + } } function onStepChanged(e, data) { diff --git a/web/app/assets/javascripts/wizard/gear/step_select_gear.js b/web/app/assets/javascripts/wizard/gear/step_select_gear.js index dff39450a..c5a6d6f07 100644 --- a/web/app/assets/javascripts/wizard/gear/step_select_gear.js +++ b/web/app/assets/javascripts/wizard/gear/step_select_gear.js @@ -277,14 +277,15 @@ await assertFTUEProfile(); var $assignedInputs = $inputChannels.find('input[type="checkbox"]:checked'); var assigned = 0; - context._.each($assignedInputs, async function (assignedInput) { + for(var i = 0; i < $assignedInputs.length; i++) { + var assignedInput = $assignedInputs[i]; var $assignedInput = $(assignedInput); var assignedChannelId = $assignedInput.attr('data-id'); var newAssignment = Math.floor(assigned / 2) + 1; logger.debug("re-assigning input channel %o to track: %o", assignedChannelId, newAssignment); await context.jamClient.TrackSetAssignment(assignedChannelId, true, newAssignment); assigned += 1; - }); + } } async function reassignOutputChannels() { diff --git a/web/app/assets/javascripts/wizard/gear_utils.js b/web/app/assets/javascripts/wizard/gear_utils.js index 90bf655b9..786e11e3f 100644 --- a/web/app/assets/javascripts/wizard/gear_utils.js +++ b/web/app/assets/javascripts/wizard/gear_utils.js @@ -201,19 +201,23 @@ var loadedDevices = {}; // augment these devices by determining their type - context._.each(devices.devices, async function (device) { + console.log("DEVICE S DEVICES", devices.devices, devices.devices.length) + + for (let index = 0; index < devices.devices.length; index++) { + let device = devices.devices[index]; + console.log("index device", index, device) if (device.name == "JamKazam Virtual Monitor") { - return; + continue; } if (device.name == JAMKAZAM_VIRTUAL_INPUT) { - return; + continue; } if ((device.name == 'Default Input' || device.name == 'Default Output') && operatingSystem == 'Win32'){ console.log("dropping " + device.name) - return; + continue; } var deviceInfo = {}; @@ -221,17 +225,18 @@ deviceInfo.id = device.guid; deviceInfo.port_audio_name = device.port_audio_name; deviceInfo.type = await determineDeviceType(device.guid, device.display_name); - console.log('device', device) - console.log('deviceInfo', deviceInfo) + //console.log('device', device) + //console.log('deviceInfo', deviceInfo) deviceInfo.displayType = AUDIO_DEVICE_BEHAVIOR[deviceInfo.type].display; deviceInfo.displayName = device.display_name; deviceInfo.inputCount = device.input_count; deviceInfo.outputCount = device.output_count; loadedDevices[device.guid] = deviceInfo; - }) + } - logger.debug(context.JK.dlen(loadedDevices) + " devices loaded.", loadedDevices); + + console.log(context.JK.dlen(loadedDevices) + " devices loaded.", loadedDevices); return loadedDevices; } @@ -782,4 +787,4 @@ } } -})(window, jQuery); \ No newline at end of file +})(window, jQuery);