Merge pull request #5950 from MaximKhlobystov/browser-detection-fix

Handling the case when browser detection package fails.
This commit is contained in:
Anton Georgiev 2018-08-01 13:48:34 -04:00 committed by GitHub
commit 1fdbfb6284
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 5 deletions

View File

@ -34,8 +34,10 @@ const intlMessages = defineMessages({
});
const BROWSER_RESULTS = browser();
const isMobileBrowser = BROWSER_RESULTS.mobile ||
BROWSER_RESULTS.os.includes('Android'); // mobile flag doesn't always work
const isMobileBrowser = (BROWSER_RESULTS ? BROWSER_RESULTS.mobile : false) ||
(BROWSER_RESULTS && BROWSER_RESULTS.os ?
BROWSER_RESULTS.os.includes('Android') : // mobile flag doesn't always work
false);
const screenSharingCheck = Meteor.settings.public.kurento.enableScreensharing;
const DesktopShare = ({

View File

@ -81,8 +81,12 @@ class App extends Component {
const BROWSER_RESULTS = browser();
const body = document.getElementsByTagName('body')[0];
body.classList.add(`browser-${BROWSER_RESULTS.name}`);
body.classList.add(`os-${BROWSER_RESULTS.os.split(' ').shift().toLowerCase()}`);
if (BROWSER_RESULTS && BROWSER_RESULTS.name) {
body.classList.add(`browser-${BROWSER_RESULTS.name}`);
}
if (BROWSER_RESULTS && BROWSER_RESULTS.os) {
body.classList.add(`os-${BROWSER_RESULTS.os.split(' ').shift().toLowerCase()}`);
}
this.handleWindowResize();
window.addEventListener('resize', this.handleWindowResize, false);

View File

@ -53,7 +53,7 @@ export default class SettingsDropdownContainer extends Component {
const handleToggleFullscreen = toggleFullScreen;
const isFullScreen = this.state.isFullScreen;
const result = browser();
const isAndroid = result.os.includes('Android');
const isAndroid = (result && result.os) ? result.os.includes('Android') : false;
return (
<SettingsDropdown