Use compare-versions for all version checks

This commit is contained in:
Bill Thornton 2021-04-19 11:09:25 -04:00
parent 2a1f613c17
commit 14f293e545
2 changed files with 8 additions and 6 deletions

View File

@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import compareVersions from 'compare-versions';
import { action, computed, decorate, observable } from 'mobx';
import { Platform } from 'react-native';
@ -25,7 +26,7 @@ export default class SettingStore {
/**
* Is screen lock active when media is playing
*/
isScreenLockEnabled = Platform.OS === 'ios' ? (parseInt(Platform.Version, 10) < 14) : true
isScreenLockEnabled = Platform.OS === 'ios' ? !!Platform.Version && compareVersions.compare(Platform.Version, '14', '<') : true
/**
* Are tab labels enabled
@ -65,7 +66,7 @@ export default class SettingStore {
reset() {
this.activeServer = 0;
this.isRotationLockEnabled = Platform.OS === 'ios' && !Platform.isPad;
this.isScreenLockEnabled = Platform.OS === 'ios' ? (parseInt(Platform.Version, 10) < 14) : true;
this.isScreenLockEnabled = Platform.OS === 'ios' ? !!Platform.Version && compareVersions.compare(Platform.Version, '14', '<') : true;
this.isTabLabelsEnabled = true;
this.themeId = 'dark';
this.systemThemeId = null;

View File

@ -3,6 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
import compareVersions from 'compare-versions';
import Constants from 'expo-constants';
import * as Device from 'expo-device';
import { Platform } from 'react-native';
@ -33,9 +34,9 @@ export function getSafeDeviceName() {
export function getDeviceProfile({ enableFmp4 = false } = {}) {
if (Platform.OS === 'ios') {
if (parseInt(Platform.Version, 10) < 11) {
if (compareVersions.compare(Platform.Version, '11', '<')) {
return iOS10Profile;
} else if (parseInt(Platform.Version, 10) < 13) {
} else if (compareVersions.compare(Platform.Version, '13', '<')) {
return iOS12Profile;
} else if (enableFmp4) {
return iOSFmp4Profile;
@ -53,6 +54,6 @@ export function isCompact({ height = 500 } = {}) {
// Does the platform support system level themes: https://docs.expo.io/versions/latest/sdk/appearance/
export function isSystemThemeSupported() {
return (Platform.OS === 'ios' && parseInt(Platform.Version, 10) > 12) ||
(Platform.OS === 'android' && parseInt(Platform.Version, 10) > 9);
return (Platform.OS === 'ios' && compareVersions.compare(Platform.Version, '12', '>')) ||
(Platform.OS === 'android' && compareVersions.compare(Platform.Version, '9', '>'));
}