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

@ -12,7 +12,7 @@ export function enable(enabled) {
if (enabled) {
const currentPlayerInfo = playbackManager.getPlayerInfo();
if (currentPlayerInfo && currentPlayerInfo.id) {
if (currentPlayerInfo?.id) {
localStorage.setItem('autocastPlayerId', currentPlayerInfo.id);
}
} else {

View file

@ -3,7 +3,7 @@ import * as userSettings from './settings/userSettings';
import browser from './browser';
function canPlayH264(videoTestElement) {
return !!(videoTestElement.canPlayType && videoTestElement.canPlayType('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
return !!(videoTestElement.canPlayType?.('video/mp4; codecs="avc1.42E01E, mp4a.40.2"').replace(/no/, ''));
}
function canPlayHevc(videoTestElement, options) {

View file

@ -15,7 +15,7 @@ export function parentWithAttribute(elem, name, value) {
while ((value ? elem.getAttribute(name) !== value : !elem.getAttribute(name))) {
elem = elem.parentNode;
if (!elem || !elem.getAttribute) {
if (!elem?.getAttribute) {
return null;
}
}

View file

@ -349,7 +349,7 @@ function isGamepadConnected() {
const gamepads = navigator.getGamepads(); /* eslint-disable-line compat/compat */
for (let i = 0, len = gamepads.length; i < len; i++) {
const gamepad = gamepads[i];
if (gamepad && gamepad.connected) {
if (gamepad?.connected) {
return true;
}
}

View file

@ -37,7 +37,7 @@ function getDefaultLanguage() {
if (navigator.userLanguage) {
return navigator.userLanguage;
}
if (navigator.languages && navigator.languages.length) {
if (navigator.languages?.length) {
return navigator.languages[0];
}
@ -217,12 +217,12 @@ function translateKey(key) {
function translateKeyFromModule(key, module) {
let dictionary = getDictionary(module, getCurrentLocale());
if (dictionary && dictionary[key]) {
if (dictionary?.[key]) {
return dictionary[key];
}
dictionary = getDictionary(module, fallbackCulture);
if (dictionary && dictionary[key]) {
if (dictionary?.[key]) {
return dictionary[key];
}

View file

@ -71,7 +71,7 @@ function renderHeader() {
}
function getCurrentApiClient() {
if (currentUser && currentUser.localUser) {
if (currentUser?.localUser) {
return ServerConnections.getApiClient(currentUser.localUser.ServerId);
}
@ -127,7 +127,7 @@ function updateUserInHeader(user) {
let hasImage;
if (user && user.name) {
if (user?.name) {
if (user.imageUrl) {
const url = user.imageUrl;
updateHeaderUserButton(url);
@ -143,7 +143,7 @@ function updateUserInHeader(user) {
updateHeaderUserButton(null);
}
if (user && user.localUser) {
if (user?.localUser) {
if (headerHomeButton) {
headerHomeButton.classList.remove('hide');
}
@ -322,7 +322,7 @@ function refreshLibraryInfoInDrawer(user) {
// libraries are added here
html += '<div class="libraryMenuOptions"></div>';
if (user.localUser && user.localUser.Policy.IsAdministrator) {
if (user.localUser?.Policy.IsAdministrator) {
html += '<div class="adminMenuOptions">';
html += '<h3 class="sidebarHeader">';
html += globalize.translate('HeaderAdmin');

View file

@ -94,7 +94,7 @@ function ScreenSaverManager() {
let isLoggedIn;
const apiClient = ServerConnections.currentApiClient();
if (apiClient && apiClient.isLoggedIn()) {
if (apiClient?.isLoggedIn()) {
isLoggedIn = true;
}