openvidu-browser: Reformat function checkSystemRequirements()

It was difficult to read and modify, and the "if/else" return logic
could be simplified.

Also the comments were outdated. Remove them and let the code speak
by itself.
pull/672/merge
Juan Navarro 2022-07-27 16:46:38 +02:00
parent 80ed795c65
commit b5d7371eed
1 changed files with 25 additions and 20 deletions

View File

@ -304,29 +304,34 @@ export class OpenVidu {
* Checks if the browser supports OpenVidu * Checks if the browser supports OpenVidu
* @returns 1 if the browser supports OpenVidu, 0 otherwise * @returns 1 if the browser supports OpenVidu, 0 otherwise
*/ */
checkSystemRequirements(): number { checkSystemRequirements(): boolean {
// Specific iOS platform support (iPhone, iPad)
if (platform.isIPhoneOrIPad()) { if (platform.isIPhoneOrIPad()) {
if (platform.isIOSWithSafari() || platform.isIonicIos() || return (
platform.isChromeMobileBrowser() || platform.isEdgeMobileBrowser() || platform.isOperaMobileBrowser() || platform.isFirefoxMobileBrowser()) { platform.isIOSWithSafari() ||
return 1; platform.isChromeMobileBrowser() ||
} platform.isFirefoxMobileBrowser() ||
return 0; platform.isOperaMobileBrowser() ||
platform.isEdgeMobileBrowser() ||
platform.isIonicIos() // Ionic apps for iOS
);
} }
// Accept: Chrome (desktop and Android), Firefox (desktop and Android), Opera (desktop and Android), // General platform support for web clients (Desktop, Mobile)
// Safari (OSX and iOS), Edge Chromium (>= 80), Ionic (Android and iOS), Samsung Internet Browser (Android) return (
if (platform.isChromeBrowser() || platform.isChromeMobileBrowser() || platform.isChromeBrowser() ||
platform.isFirefoxBrowser() || platform.isFirefoxMobileBrowser() || platform.isOperaBrowser() || platform.isChromeMobileBrowser() ||
platform.isOperaMobileBrowser() || platform.isEdgeBrowser() || platform.isEdgeMobileBrowser() || platform.isFirefoxBrowser() ||
platform.isSafariBrowser() || platform.isAndroidBrowser() || platform.isElectron() || platform.isSamsungBrowser() platform.isFirefoxMobileBrowser() ||
) { platform.isOperaBrowser() ||
return 1; platform.isOperaMobileBrowser() ||
} platform.isEdgeBrowser() ||
// Reject iPhones and iPads if not Safari ('Safari' also covers Ionic for iOS) platform.isEdgeMobileBrowser() ||
// Reject others browsers not mentioned above platform.isSamsungBrowser() ||
return 0; platform.isSafariBrowser() ||
platform.isAndroidBrowser() || // Android WebView & Ionic apps for Android
platform.isElectron()
);
} }
/** /**