refactor selfhosted app detection

This commit is contained in:
antelle 2017-05-28 17:30:00 +02:00
parent 928be7b8e4
commit a39b4e63a1
2 changed files with 7 additions and 5 deletions

View File

@ -1,6 +1,6 @@
const StorageBase = require('./storage-base');
const UrlUtil = require('../util/url-util');
const Launcher = require('../comp/launcher');
const FeatureDetector = require('../util/feature-detector');
const DropboxKeys = {
AppFolder: 'qp7ctun6qt5n9d6',
@ -59,9 +59,7 @@ const StorageDropbox = StorageBase.extend({
},
_canUseBuiltInKeys: function() {
const isSelfHosted = !/^http(s?):\/\/localhost:8085/.test(location.href) &&
!/http(s?):\/\/(app|beta)\.keeweb\.info/.test(location.href);
return !!Launcher || !isSelfHosted;
return !FeatureDetector.isSelfHosted;
},
_getOAuthConfig: function() {

View File

@ -1,7 +1,10 @@
const MobileRegex = /iPhone|iPad|iPod|Android|BlackBerry|Opera Mini|IEMobile|WPDesktop|Windows Phone|webOS/i;
const MinDesktopScreenWidth = 800;
const isDesktop = !!(window.process && window.process.versions && window.process.versions.electron);
const FeatureDetector = {
isDesktop: isDesktop,
isMac: navigator.platform.indexOf('Mac') >= 0,
isWindows: navigator.platform.indexOf('Win') >= 0,
isiOS: /iPad|iPhone|iPod/i.test(navigator.userAgent),
@ -9,6 +12,7 @@ const FeatureDetector = {
isPopup: !!((window.parent !== window.top) || window.opener),
isStandalone: !!navigator.standalone,
isBeta: window.location.href.toLowerCase().indexOf('beta.') > 0,
isSelfHosted: !isDesktop && !/^http(s?):\/\/((localhost:8085)|((app|beta)\.keeweb\.info))/.test(location.href),
needFixClicks: /Edge\/14/.test(navigator.appVersion),
actionShortcutSymbol: function(formatting) {
@ -40,7 +44,7 @@ const FeatureDetector = {
if (!window.crypto) {
throw 'WebCrypto not available';
}
if (!localStorage.length && (!window.process || !window.process.versions || !window.process.versions.electron)) {
if (!localStorage.length && !isDesktop) {
try {
localStorage.appSettings = '';
} catch (e) {