Skip to content

Commit

Permalink
[IMPROVE] Remove too specific helpers isFirefox() and isChrome() (#14963
Browse files Browse the repository at this point in the history
)
  • Loading branch information
tassoevan authored and ggazzo committed Jul 11, 2019
1 parent ea1c99f commit 8397e2d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
17 changes: 15 additions & 2 deletions app/ui/client/components/icon.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
import { FlowRouter } from 'meteor/kadira:flow-router';
import { Template } from 'meteor/templating';

import { isChrome, isFirefox } from '../../../utils';
import './icon.html';


const baseUrlFix = () => `${ document.baseURI }${ FlowRouter.current().path.substring(1) }`;

const isMozillaFirefoxBelowVersion = (upperVersion) => {
const [, version] = navigator.userAgent.match(/Firefox\/(\d+)\.\d/) || [];
return parseInt(version, 10) < upperVersion;
};

const isGoogleChromeBelowVersion = (upperVersion) => {
const [, version] = navigator.userAgent.match(/Chrome\/(\d+)\.\d/) || [];
return parseInt(version, 10) < upperVersion;
};

const isBaseUrlFixNeeded = () => isMozillaFirefoxBelowVersion(55) || isGoogleChromeBelowVersion(55);

Template.icon.helpers({
baseUrl: (isFirefox && isFirefox[1] < 55) || (isChrome && isChrome[1] < 55) ? baseUrlFix : undefined,
baseUrl: isBaseUrlFixNeeded() ? baseUrlFix : undefined,
});
1 change: 0 additions & 1 deletion app/ui/client/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import './views/app/secretURL';
import './views/app/videoCall/videoButtons';
import './views/app/videoCall/videoCall';
import './views/app/photoswipe';
import './components/icon.html';
import './components/icon';
import './components/table.html';
import './components/table';
Expand Down
1 change: 0 additions & 1 deletion app/utils/client/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export { t, isRtl } from '../lib/tapi18n';
export { isChrome, isFirefox } from './lib/browsers';
export { getDefaultSubscriptionPref } from '../lib/getDefaultSubscriptionPref';
export { Info } from '../rocketchat.info';
export { isEmail } from '../lib/isEmail';
Expand Down
2 changes: 0 additions & 2 deletions app/utils/client/lib/browsers.js

This file was deleted.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8397e2d

Please sign in to comment.