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

Add prefer optional chaining rule

This commit is contained in:
Bill Thornton 2023-07-06 13:39:48 -04:00
parent ec0adb895b
commit f35a8151e0
61 changed files with 152 additions and 152 deletions

View file

@ -384,7 +384,7 @@ export class BookPlayer {
}
canPlayItem(item) {
return item.Path && item.Path.endsWith('epub');
return item.Path?.endsWith('epub');
}
}

View file

@ -103,7 +103,7 @@ class CastPlayer {
return;
}
if (!chrome.cast || !chrome.cast.isAvailable) {
if (!chrome.cast?.isAvailable) {
setTimeout(this.initializeCastPlayer.bind(this), 1000);
return;
}
@ -322,14 +322,14 @@ class CastPlayer {
const session = player.session;
if (session && session.receiver && session.receiver.friendlyName) {
if (session?.receiver?.friendlyName) {
receiverName = session.receiver.friendlyName;
}
let apiClient;
if (message.options && message.options.ServerId) {
if (message.options?.ServerId) {
apiClient = ServerConnections.getApiClient(message.options.ServerId);
} else if (message.options && message.options.items && message.options.items.length) {
} else if (message.options?.items?.length) {
apiClient = ServerConnections.getApiClient(message.options.items[0].ServerId);
} else {
apiClient = ServerConnections.currentApiClient();
@ -350,7 +350,7 @@ class CastPlayer {
message.maxBitrate = bitrateSetting;
}
if (message.options && message.options.items) {
if (message.options?.items) {
message.subtitleAppearance = userSettings.getSubtitleAppearanceSettings();
message.subtitleBurnIn = appSettings.get('subtitleburnin') || '';
}
@ -451,10 +451,10 @@ function onVolumeDownKeyDown() {
}
function normalizeImages(state) {
if (state && state.NowPlayingItem) {
if (state?.NowPlayingItem) {
const item = state.NowPlayingItem;
if ((!item.ImageTags || !item.ImageTags.Primary) && item.PrimaryImageTag) {
if ((!item.ImageTags?.Primary) && item.PrimaryImageTag) {
item.ImageTags = item.ImageTags || {};
item.ImageTags.Primary = item.PrimaryImageTag;
}
@ -599,7 +599,7 @@ class ChromecastPlayer {
getTargets() {
const targets = [];
if (this._castPlayer && this._castPlayer.hasReceivers) {
if (this._castPlayer?.hasReceivers) {
targets.push(this.getCurrentTargetInfo());
}
@ -612,7 +612,7 @@ class ChromecastPlayer {
const castPlayer = this._castPlayer;
if (castPlayer.session && castPlayer.session.receiver && castPlayer.session.receiver.friendlyName) {
if (castPlayer.session?.receiver?.friendlyName) {
appName = castPlayer.session.receiver.friendlyName;
}

View file

@ -413,7 +413,7 @@ class HtmlAudioPlayer {
const mediaElement = this._mediaElement;
if (mediaElement) {
const seekable = mediaElement.seekable;
if (seekable && seekable.length) {
if (seekable?.length) {
let start = seekable.start(0);
let end = seekable.end(0);

View file

@ -1010,7 +1010,7 @@ export class HtmlVideoPlayer {
}
if (elem.videoWidth === 0 && elem.videoHeight === 0) {
const mediaSource = (this._currentPlayOptions || {}).mediaSource;
const mediaSource = this._currentPlayOptions?.mediaSource;
// Only trigger this if there is media info
// Avoid triggering in situations where it might not actually have a video stream (audio only live tv channel)
@ -1536,7 +1536,7 @@ export class HtmlVideoPlayer {
}
}
if (selectedTrackEvent && selectedTrackEvent.Text) {
if (selectedTrackEvent?.Text) {
subtitleTextElement.innerHTML = DOMPurify.sanitize(
normalizeTrackEventText(selectedTrackEvent.Text, true));
subtitleTextElement.classList.remove('hide');
@ -1812,7 +1812,7 @@ export class HtmlVideoPlayer {
Windows.UI.ViewManagement.ApplicationView.getForCurrentView().tryEnterViewModeAsync(Windows.UI.ViewManagement.ApplicationViewMode.default);
}
} else {
if (video && video.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') {
if (video?.webkitSupportsPresentationMode && typeof video.webkitSetPresentationMode === 'function') {
video.webkitSetPresentationMode(isEnabled ? 'picture-in-picture' : 'inline');
}
}
@ -1891,7 +1891,7 @@ export class HtmlVideoPlayer {
const mediaElement = this.#mediaElement;
if (mediaElement) {
const seekable = mediaElement.seekable;
if (seekable && seekable.length) {
if (seekable?.length) {
let start = seekable.start(0);
let end = seekable.end(0);

View file

@ -25,7 +25,7 @@ export default function () {
const elem = document.querySelector('.logoScreenSaverImage');
if (elem && elem.animate) {
if (elem?.animate) {
const random = randomInt(0, animations.length - 1);
animations[random](elem, 1);

View file

@ -312,7 +312,7 @@ export class PdfPlayer {
}
canPlayItem(item) {
return item.Path && item.Path.endsWith('pdf');
return item.Path?.endsWith('pdf');
}
}

View file

@ -157,7 +157,7 @@ function subscribeToPlayerUpdates(instance) {
}
function normalizeImages(state, apiClient) {
if (state && state.NowPlayingItem) {
if (state?.NowPlayingItem) {
const item = state.NowPlayingItem;
if (!item.ImageTags || !item.ImageTags.Primary && item.PrimaryImageTag) {