From f1bb30ea0d63e43ba7a86b637d2d4fb0da599433 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Sun, 15 Jun 2014 21:42:57 -0500 Subject: [PATCH] * VRFS-1788 - adding simple 'loop detection' logic --- web/app/assets/javascripts/voiceChatHelper.js | 40 ++++++++++++++----- .../assets/javascripts/wizard/gear_utils.js | 1 - 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/web/app/assets/javascripts/voiceChatHelper.js b/web/app/assets/javascripts/voiceChatHelper.js index 111665557..e78aa00cb 100644 --- a/web/app/assets/javascripts/voiceChatHelper.js +++ b/web/app/assets/javascripts/voiceChatHelper.js @@ -31,6 +31,7 @@ var vuOptions = null; var faderHeight = null; var startingState = null; + var resettedOnInvalidDevice = false; // this is set to true when we clear chat, and set to false when the user interacts in anyway function defaultReuse() { suppressChange(function(){ @@ -45,12 +46,22 @@ function onInvalidAudioDevice(e, data) { logger.debug("voice_chat_helper: onInvalidAudioDevice") + + if(resettedOnInvalidDevice) { + // we've already tried to clear the audio device, and the user hasn't interacted, but still we are getting this event + // we can't keep taking action, so stop + logger.error("voice_chat_helper: onInvalidAudioDevice: ignoring event because we have already tried to handle it"); + return; + } + resettedOnInvalidDevice = true; + $selectedChatInput = null; // you can't do this in the event callback; it hangs the app indefinitely, and somehow 'sticks' the mic input into bad state until reboot setTimeout(function() { context.jamClient.FTUEClearChatInput(); context.jamClient.TrackSetChatEnable(true); var result = context.jamClient.TrackSaveAssignments(); + if(!result || result.length == 0) { context.JK.Banner.showAlert('It appears the selected chat input is not functioning. Please try another chat input.'); } @@ -61,6 +72,7 @@ } function beforeShow() { + userInteracted(); renderNoVolume(); context.JK.onBackendEvent(ALERT_NAMES.AUDIO_DEVICE_NOT_PRESENT, 'voice_chat_helper', onInvalidAudioDevice); registerVuCallbacks(); @@ -70,6 +82,10 @@ jamClient.FTUERegisterVUCallbacks('', '', ''); } + function userInteracted() { + resettedOnInvalidDevice = false; + } + function reset(forceDisabledChat) { $selectedChatInput = null; @@ -98,12 +114,13 @@ $selectedChatInput = $chatInput; $selectedChatInput.attr('checked', 'checked'); } - $chat.hide(); // we'll show it once it's styled with iCheck + //$chat.hide(); // we'll show it once it's styled with iCheck $chatInputs.append($chat); }); var $radioButtons = $chatInputs.find('input[name="chat-device"]'); context.JK.checkbox($radioButtons).on('ifChecked', function(e) { + userInteracted(); var $input = $(e.currentTarget); $selectedChatInput = $input; // for use in handleNext if(saveImmediate) { @@ -136,13 +153,6 @@ disableChatButtonsUI(); } - $chatInputs.find('.chat-input').show().on('click', function() { - // obnoxious; remove soon XXX - // if(!isChatEnabled()) { - // context.JK.prodBubble($parent.find('.use-chat-input h3'), 'chat-not-enabled', {}, { positions:['left']}); - // } - }) - renderVolumes(); startingState = getCurrentState(); @@ -246,8 +256,18 @@ $reuseAudioInputRadio.closest('.iradio_minimal').css('position', 'absolute'); $useChatInputRadio.closest('.iradio_minimal').css('position', 'absolute'); - $reuseAudioInputRadio.on('ifChecked', function() { if(!ignoreICheckEvent) disableChat(true) }); - $useChatInputRadio.on('ifChecked', function() { if(!ignoreICheckEvent) enableChat(true) }); + $reuseAudioInputRadio.on('ifChecked', function() { + if(!ignoreICheckEvent) { + userInteracted(); + disableChat(true); + } + }); + $useChatInputRadio.on('ifChecked', function() { + if(!ignoreICheckEvent) { + userInteracted(); + enableChat(true) + } + }); } // gets the state of the UI diff --git a/web/app/assets/javascripts/wizard/gear_utils.js b/web/app/assets/javascripts/wizard/gear_utils.js index aec58b8f9..30ba2e686 100644 --- a/web/app/assets/javascripts/wizard/gear_utils.js +++ b/web/app/assets/javascripts/wizard/gear_utils.js @@ -248,7 +248,6 @@ } }) - logger.debug("chatInputs:", chatInputs) return chatInputs; }