Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix!: remove unused or obsolete useragent checks #6355

Merged
merged 1 commit into from
Aug 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions core/utils/useragent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ let rawUserAgent: string;

let isJavaFx: boolean;

let isChrome: boolean;

let isWebKit: boolean;

let isGecko: boolean;
Expand All @@ -35,8 +33,6 @@ let isAndroid: boolean;

let isIPad: boolean;

let isIPod: boolean;

let isIPhone: boolean;

let isMac: boolean;
Expand All @@ -63,7 +59,6 @@ function has(name: string): boolean {
// Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.44
// (KHTML, like Gecko) JavaFX/8.0 Safari/537.44
isJavaFx = has('JavaFX');
isChrome = (has('Chrome') || has('CriOS'));

// Engines. Logic from:
// https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/engine.js
Expand All @@ -78,14 +73,13 @@ isAndroid = has('Android');
const maxTouchPoints =
globalThis['navigator'] && globalThis['navigator']['maxTouchPoints'];
isIPad = has('iPad') || has('Macintosh') && maxTouchPoints > 0;
isIPod = has('iPod');
isIPhone = has('iPhone') && !isIPad && !isIPod;
isIPhone = has('iPhone') && !isIPad;
isMac = has('Macintosh');

// Devices. Logic from:
// https://github.com/google/closure-library/blob/master/closure/goog/labs/useragent/device.js
isTablet = isIPad || isAndroid && !has('Mobile') || has('Silk');
isMobile = !isTablet && (isIPod || isIPhone || isAndroid || has('IEMobile'));
isMobile = !isTablet && (isIPhone || isAndroid);
})(globalThis['navigator'] && globalThis['navigator']['userAgent'] || '');

/** @alias Blockly.utils.userAgent.raw */
Expand All @@ -94,12 +88,6 @@ export const raw: string = rawUserAgent;
/** @alias Blockly.utils.userAgent.JavaFx */
export const JavaFx: boolean = isJavaFx;

/** @alias Blockly.utils.userAgent.CHROME */
export const CHROME: boolean = isChrome;

/** @alias Blockly.utils.userAgent.WEBKIT */
export const WEBKIT: boolean = isWebKit;

/** @alias Blockly.utils.userAgent.GECKO */
export const GECKO: boolean = isGecko;

Expand All @@ -108,17 +96,12 @@ export const ANDROID: boolean = isAndroid;

/** @alias Blockly.utils.userAgent.IPAD */
export const IPAD: boolean = isIPad;
/** @alias Blockly.utils.userAgent.IPOD */
export const IPOD: boolean = isIPod;

/** @alias Blockly.utils.userAgent.IPHONE */
export const IPHONE: boolean = isIPhone;

/** @alias Blockly.utils.userAgent.MAC */
export const MAC: boolean = isMac;

/** @alias Blockly.utils.userAgent.TABLET */
export const TABLET: boolean = isTablet;

/** @alias Blockly.utils.userAgent.MOBILE */
export const MOBILE: boolean = isMobile;