mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Refactor getDeviceName() for readability (#6319)
* Refactor getDeviceName() for readability Refactored a long if-else into a cleaner, easier to extend mapping * Apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * Move BrowserName to the top of the file Renamed deviceMappings to BrowserName and moved it under the appName declaration as requested --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
d7a6d8d4f0
commit
9329e2279d
2 changed files with 31 additions and 32 deletions
|
@ -8,6 +8,20 @@ import profileBuilder from '../scripts/browserDeviceProfile';
|
|||
|
||||
const appName = 'Jellyfin Web';
|
||||
|
||||
const BrowserName = {
|
||||
tizen: 'Samsung Smart TV',
|
||||
web0s: 'LG Smart TV',
|
||||
operaTv: 'Opera TV',
|
||||
xboxOne: 'Xbox One',
|
||||
ps4: 'Sony PS4',
|
||||
chrome: 'Chrome',
|
||||
edgeChromium: 'Edge Chromium',
|
||||
edge: 'Edge',
|
||||
firefox: 'Firefox',
|
||||
opera: 'Opera',
|
||||
safari: 'Safari'
|
||||
};
|
||||
|
||||
function getBaseProfileOptions(item) {
|
||||
const disableHlsVideoAudioCodecs = [];
|
||||
|
||||
|
@ -132,42 +146,26 @@ function getDeviceId() {
|
|||
}
|
||||
|
||||
function getDeviceName() {
|
||||
if (!deviceName) {
|
||||
if (browser.tizen) {
|
||||
deviceName = 'Samsung Smart TV';
|
||||
} else if (browser.web0s) {
|
||||
deviceName = 'LG Smart TV';
|
||||
} else if (browser.operaTv) {
|
||||
deviceName = 'Opera TV';
|
||||
} else if (browser.xboxOne) {
|
||||
deviceName = 'Xbox One';
|
||||
} else if (browser.ps4) {
|
||||
deviceName = 'Sony PS4';
|
||||
} else if (browser.chrome) {
|
||||
deviceName = 'Chrome';
|
||||
} else if (browser.edgeChromium) {
|
||||
deviceName = 'Edge Chromium';
|
||||
} else if (browser.edge) {
|
||||
deviceName = 'Edge';
|
||||
} else if (browser.firefox) {
|
||||
deviceName = 'Firefox';
|
||||
} else if (browser.opera) {
|
||||
deviceName = 'Opera';
|
||||
} else if (browser.safari) {
|
||||
deviceName = 'Safari';
|
||||
} else {
|
||||
deviceName = 'Web Browser';
|
||||
}
|
||||
if (deviceName) {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
if (browser.ipad) {
|
||||
deviceName += ' iPad';
|
||||
} else if (browser.iphone) {
|
||||
deviceName += ' iPhone';
|
||||
} else if (browser.android) {
|
||||
deviceName += ' Android';
|
||||
deviceName = 'Web Browser'; // Default device name
|
||||
|
||||
for (const key in BrowserName) {
|
||||
if (browser[key]) {
|
||||
deviceName = BrowserName[key];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (browser.ipad) {
|
||||
deviceName += ' iPad';
|
||||
} else if (browser.iphone) {
|
||||
deviceName += ' iPhone';
|
||||
} else if (browser.android) {
|
||||
deviceName += ' Android';
|
||||
}
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue