From 89853dc026542247bdbcf32744bb7155ef3c11a8 Mon Sep 17 00:00:00 2001 From: KDSBrowne <kert.browne85@gmail.com> Date: Mon, 30 Sep 2019 14:54:34 +0000 Subject: [PATCH] move microphone error codes to const --- .../ui/components/audio/audio-modal/component.jsx | 8 +++++++- .../ui/components/audio/audio-modal/container.jsx | 3 ++- .../imports/ui/components/audio/help/component.jsx | 11 +++++++---- .../imports/ui/services/audio-manager/error-codes.js | 7 +++++++ .../imports/ui/services/audio-manager/index.js | 12 +++++++----- 5 files changed, 30 insertions(+), 11 deletions(-) create mode 100644 bigbluebutton-html5/imports/ui/services/audio-manager/error-codes.js diff --git a/bigbluebutton-html5/imports/ui/components/audio/audio-modal/component.jsx b/bigbluebutton-html5/imports/ui/components/audio/audio-modal/component.jsx index 005b7ea0ab..06dae909d2 100755 --- a/bigbluebutton-html5/imports/ui/components/audio/audio-modal/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/audio/audio-modal/component.jsx @@ -444,11 +444,17 @@ class AudioModal extends Component { renderHelp() { const { errCode } = this.state; + const { AudioError } = this.props; + + const audioErr = { + ...AudioError, + code: errCode, + }; return ( <Help handleBack={this.handleGoToAudioOptions} - errCode={errCode} + audioErr={audioErr} /> ); } diff --git a/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx b/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx index 94b88889a3..13e4335675 100755 --- a/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx +++ b/bigbluebutton-html5/imports/ui/components/audio/audio-modal/container.jsx @@ -8,6 +8,7 @@ import Meetings from '/imports/api/meetings'; import Auth from '/imports/ui/services/auth'; import deviceInfo from '/imports/utils/deviceInfo'; import lockContextContainer from '/imports/ui/components/lock-viewers/context/container'; +import AudioError from '/imports/ui/services/audio-manager/error-codes'; import Service from '../service'; const AudioModalContainer = props => <AudioModal {...props} />; @@ -17,7 +18,6 @@ const APP_CONFIG = Meteor.settings.public.app; const invalidDialNumbers = ['0', '613-555-1212', '613-555-1234', '0000']; const isRTL = document.documentElement.getAttribute('dir') === 'rtl'; - export default lockContextContainer(withModalMounter(withTracker(({ mountModal, userLocks }) => { const listenOnlyMode = getFromUserSettings('listenOnlyMode', APP_CONFIG.listenOnlyMode); const forceListenOnly = getFromUserSettings('forceListenOnly', APP_CONFIG.forceListenOnly); @@ -106,5 +106,6 @@ export default lockContextContainer(withModalMounter(withTracker(({ mountModal, autoplayBlocked: Service.autoplayBlocked(), handleAllowAutoplay: () => Service.handleAllowAutoplay(), isRTL, + AudioError, }); })(AudioModalContainer))); diff --git a/bigbluebutton-html5/imports/ui/components/audio/help/component.jsx b/bigbluebutton-html5/imports/ui/components/audio/help/component.jsx index e6ddb92eb6..4bdc51681e 100644 --- a/bigbluebutton-html5/imports/ui/components/audio/help/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/audio/help/component.jsx @@ -27,18 +27,21 @@ class Help extends Component { const { intl, handleBack, - errCode, + audioErr, } = this.props; + const { code, MIC_ERROR } = audioErr; + let helpMessage = null; - switch (errCode) { - case 2: + switch (code) { + case MIC_ERROR.NO_SSL: helpMessage = intl.formatMessage(intlMessages.noSSL); break; - case 3: + case MIC_ERROR.MAC_OS_BLOCK: helpMessage = intl.formatMessage(intlMessages.macNotAllowed); break; + case MIC_ERROR.NO_PERMISSION: default: helpMessage = intl.formatMessage(intlMessages.descriptionHelp); break; diff --git a/bigbluebutton-html5/imports/ui/services/audio-manager/error-codes.js b/bigbluebutton-html5/imports/ui/services/audio-manager/error-codes.js new file mode 100644 index 0000000000..7e8fede881 --- /dev/null +++ b/bigbluebutton-html5/imports/ui/services/audio-manager/error-codes.js @@ -0,0 +1,7 @@ +const MIC_ERROR = { + NO_SSL: 9, + MAC_OS_BLOCK: 8, + NO_PERMISSION: 7, +}; + +export default { MIC_ERROR }; diff --git a/bigbluebutton-html5/imports/ui/services/audio-manager/index.js b/bigbluebutton-html5/imports/ui/services/audio-manager/index.js index 5a717942c9..3611daebd7 100755 --- a/bigbluebutton-html5/imports/ui/services/audio-manager/index.js +++ b/bigbluebutton-html5/imports/ui/services/audio-manager/index.js @@ -6,9 +6,10 @@ import SIPBridge from '/imports/api/audio/client/bridge/sip'; import logger from '/imports/startup/client/logger'; import { notify } from '/imports/ui/services/notification'; import browser from 'browser-detect'; +import playAndRetry from '/imports/utils/mediaElementPlayRetry'; import iosWebviewAudioPolyfills from '../../../utils/ios-webview-audio-polyfills'; import { tryGenerateIceCandidates } from '../../../utils/safari-webrtc'; -import playAndRetry from '/imports/utils/mediaElementPlayRetry'; +import AudioErrors from './error-codes'; const MEDIA = Meteor.settings.public.media; const MEDIA_TAG = MEDIA.mediaTag; @@ -433,13 +434,14 @@ class AudioManager { }, }, `Error getting microphone - {${error.name}: ${error.message}}`); + const { MIC_ERROR } = AudioErrors; const disabledSysSetting = error.message.includes('Permission denied by system'); - const isMac = navigator.platform.indexOf('Mac') != -1; + const isMac = navigator.platform.indexOf('Mac') !== -1; const noSSL = !window.location.protocol.includes('https'); - let code = 1; - if (noSSL) code = 2; - if (isMac && disabledSysSetting) code = 3; + let code = MIC_ERROR.NO_PERMISSION; + if (noSSL) code = MIC_ERROR.NO_SSL; + if (isMac && disabledSysSetting) code = MIC_ERROR.MAC_OS_BLOCK; return Promise.reject({ type: 'MEDIA_ERROR', -- GitLab