Platform string for components

This commit is contained in:
Mo Bitar
2018-10-27 11:21:58 -05:00
parent 6822e5fc1c
commit f6116ff9fe
3 changed files with 21 additions and 16 deletions

View File

@@ -24,6 +24,24 @@ function parametersFromURL(url) {
return obj;
}
function getPlatformString() {
try {
var platform = navigator.platform.toLowerCase();
var trimmed = "";
if(platform.indexOf("mac") !== -1) {
trimmed = "mac";
} else if(platform.indexOf("win") !== -1) {
trimmed = "windows";
} if(platform.indexOf("linux") !== -1) {
trimmed = "linux";
}
return trimmed + (isDesktopApplication() ? "-desktop" : "-web");
} catch (e) {
return null;
}
}
function isDesktopApplication() {
return window && window.process && window.process.type && window.process.versions["electron"];
}

View File

@@ -4,21 +4,7 @@ angular.module('app')
storageManager.initialize(passcodeManager.hasPasscode(), authManager.isEphemeralSession());
try {
$scope.platform = function() {
var platform = navigator.platform.toLowerCase();
var trimmed = "";
if(platform.indexOf("mac") !== -1) {
trimmed = "mac";
} else if(platform.indexOf("win") !== -1) {
trimmed = "windows";
} if(platform.indexOf("linux") !== -1) {
trimmed = "linux";
}
return trimmed + (isDesktopApplication() ? "-desktop" : "-web");
}();
} catch (e) {}
$scope.platform = getPlatformString();
$scope.onUpdateAvailable = function(version) {
$rootScope.$broadcast('new-update-available', version);

View File

@@ -804,7 +804,8 @@ class ComponentManager {
componentData: component.componentData,
data: {
uuid: component.uuid,
environment: isDesktopApplication() ? "desktop" : "web"
environment: isDesktopApplication() ? "desktop" : "web",
platform: getPlatformString()
}
});
this.postActiveThemeToComponent(component);