optimizations for device id and name in apphost

This commit is contained in:
vitorsemeano 2020-11-08 23:11:22 +00:00
parent 5c58d1472f
commit 2b962124a5

View file

@ -64,19 +64,22 @@ function generateDeviceId() {
} }
function getDeviceId() { function getDeviceId() {
if (!deviceId) {
const key = '_deviceId2'; const key = '_deviceId2';
let deviceId = appSettings.get(key);
deviceId = appSettings.get(key);
if (!deviceId) { if (!deviceId) {
deviceId = generateDeviceId(); deviceId = generateDeviceId();
appSettings.set(key, deviceId); appSettings.set(key, deviceId);
} }
}
return deviceId; return deviceId;
} }
function getDeviceName() { function getDeviceName() {
let deviceName; if (!deviceName) {
if (browser.tizen) { if (browser.tizen) {
deviceName = 'Samsung Smart TV'; deviceName = 'Samsung Smart TV';
} else if (browser.web0s) { } else if (browser.web0s) {
@ -110,6 +113,7 @@ function getDeviceName() {
} else if (browser.android) { } else if (browser.android) {
deviceName += ' Android'; deviceName += ' Android';
} }
}
return deviceName; return deviceName;
} }
@ -311,8 +315,8 @@ function askForExit() {
}); });
} }
const deviceId = getDeviceId(); let deviceId;
const deviceName = getDeviceName(); let deviceName;
const appName = 'Jellyfin Web'; const appName = 'Jellyfin Web';
const appVersion = '10.7.0'; const appVersion = '10.7.0';
@ -352,15 +356,15 @@ export const appHost = {
} }
return { return {
deviceId, deviceId: getDeviceId(),
deviceName deviceName: getDeviceName()
}; };
}, },
deviceName: function () { deviceName: function () {
return window.NativeShell ? window.NativeShell.AppHost.deviceName() : deviceName; return window.NativeShell ? window.NativeShell.AppHost.deviceName() : getDeviceName();
}, },
deviceId: function () { deviceId: function () {
return window.NativeShell ? window.NativeShell.AppHost.deviceId() : deviceId; return window.NativeShell ? window.NativeShell.AppHost.deviceId() : getDeviceId();
}, },
appName: function () { appName: function () {
return window.NativeShell ? window.NativeShell.AppHost.appName() : appName; return window.NativeShell ? window.NativeShell.AppHost.appName() : appName;