1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Clean up appHost and shell method checking.

This commit is contained in:
Ian Walton 2021-05-04 17:35:38 -04:00
parent 17b3a2aa05
commit c4e87eb562
2 changed files with 13 additions and 11 deletions

View file

@ -360,18 +360,20 @@ export const appHost = {
};
},
deviceName: function () {
return window.NativeShell && window.NativeShell.AppHost.deviceName
return window.NativeShell?.AppHost?.deviceName
? window.NativeShell.AppHost.deviceName() : getDeviceName();
},
deviceId: function () {
return window.NativeShell && window.NativeShell.AppHost.deviceId
return window.NativeShell?.AppHost?.deviceId
? window.NativeShell.AppHost.deviceId() : getDeviceId();
},
appName: function () {
return window.NativeShell ? window.NativeShell.AppHost.appName() : appName;
return window.NativeShell?.AppHost?.appName
? window.NativeShell.AppHost.appName() : appName;
},
appVersion: function () {
return window.NativeShell ? window.NativeShell.AppHost.appVersion() : appVersion;
return window.NativeShell?.AppHost?.appVersion
? window.NativeShell.AppHost.appVersion() : appVersion;
},
getPushTokenInfo: function () {
return {};

View file

@ -1,29 +1,29 @@
// TODO: This seems like a good candidate for deprecation
export default {
enableFullscreen: function() {
if (window.NativeShell && window.NativeShell.enableFullscreen) {
if (window.NativeShell?.enableFullscreen) {
window.NativeShell.enableFullscreen();
}
},
disableFullscreen: function() {
if (window.NativeShell && window.NativeShell.disableFullscreen) {
if (window.NativeShell?.disableFullscreen) {
window.NativeShell.disableFullscreen();
}
},
openUrl: function(url, target) {
if (window.NativeShell) {
if (window.NativeShell?.openUrl) {
window.NativeShell.openUrl(url, target);
} else {
window.open(url, target || '_blank');
}
},
updateMediaSession(mediaInfo) {
if (window.NativeShell && window.NativeShell.updateMediaSession) {
if (window.NativeShell?.updateMediaSession) {
window.NativeShell.updateMediaSession(mediaInfo);
}
},
hideMediaSession() {
if (window.NativeShell && window.NativeShell.hideMediaSession) {
if (window.NativeShell?.hideMediaSession) {
window.NativeShell.hideMediaSession();
}
},
@ -32,7 +32,7 @@ export default {
* Useful for e.g. remote playback.
*/
updateVolumeLevel(volume) {
if (window.NativeShell && window.NativeShell.updateVolumeLevel) {
if (window.NativeShell?.updateVolumeLevel) {
window.NativeShell.updateVolumeLevel(volume);
}
},
@ -42,7 +42,7 @@ export default {
* @returns true on success
*/
downloadFiles(items) {
if (window.NativeShell) {
if (window.NativeShell?.downloadFile) {
items.forEach(item => window.NativeShell.downloadFile(item));
return true;
}