Auto fix tseslint stylistic type checked issues

This commit is contained in:
Matthew Haughton 2024-10-30 21:44:30 +11:00
parent c53e432f27
commit d9f2311280
5 changed files with 22 additions and 47 deletions

View File

@ -304,11 +304,7 @@ export abstract class DocumentManager {
let src: string | null = null; let src: string | null = null;
if (item != null) { if (item != null) {
if ( if (item.BackdropImageTags?.length && item.Id) {
item.BackdropImageTags &&
item.BackdropImageTags.length &&
item.Id
) {
// get first backdrop of image if applicable // get first backdrop of image if applicable
src = JellyfinApi.createImageUrl( src = JellyfinApi.createImageUrl(
item.Id, item.Id,
@ -317,8 +313,7 @@ export abstract class DocumentManager {
); );
} else if ( } else if (
item.ParentBackdropItemId && item.ParentBackdropItemId &&
item.ParentBackdropImageTags && item.ParentBackdropImageTags?.length
item.ParentBackdropImageTags.length
) { ) {
// otherwise get first backdrop from parent // otherwise get first backdrop from parent
src = JellyfinApi.createImageUrl( src = JellyfinApi.createImageUrl(
@ -376,7 +371,7 @@ export abstract class DocumentManager {
let src: string | null = null; let src: string | null = null;
let item: BaseItemDto | null = null; let item: BaseItemDto | null = null;
if (result.Items && result.Items[0]) { if (result.Items?.[0]) {
item = result.Items[0]; item = result.Items[0];
src = await DocumentManager.getWaitingBackdropUrl(item); src = await DocumentManager.getWaitingBackdropUrl(item);
} }
@ -459,11 +454,7 @@ export abstract class DocumentManager {
let backdropUrl: string | null = null; let backdropUrl: string | null = null;
if ( if (item.BackdropImageTags?.length && item.Id) {
item.BackdropImageTags &&
item.BackdropImageTags.length &&
item.Id
) {
backdropUrl = JellyfinApi.createImageUrl( backdropUrl = JellyfinApi.createImageUrl(
item.Id, item.Id,
'Backdrop', 'Backdrop',
@ -471,8 +462,7 @@ export abstract class DocumentManager {
); );
} else if ( } else if (
item.ParentBackdropItemId && item.ParentBackdropItemId &&
item.ParentBackdropImageTags && item.ParentBackdropImageTags?.length
item.ParentBackdropImageTags.length
) { ) {
backdropUrl = JellyfinApi.createImageUrl( backdropUrl = JellyfinApi.createImageUrl(
item.ParentBackdropItemId, item.ParentBackdropItemId,
@ -521,7 +511,7 @@ export abstract class DocumentManager {
* @param item - source for the displayed name * @param item - source for the displayed name
*/ */
private static setDisplayName(item: BaseItemDto): void { private static setDisplayName(item: BaseItemDto): void {
const name: string = item.EpisodeTitle ?? (item.Name as string); const name: string = item.EpisodeTitle ?? item.Name!;
let displayName: string = name; let displayName: string = name;

View File

@ -128,7 +128,7 @@ export async function ajax(request: any): Promise<Response | string> {
request.dataType === 'text' || request.dataType === 'text' ||
(response.headers.get('Content-Type') || '') (response.headers.get('Content-Type') || '')
.toLowerCase() .toLowerCase()
.indexOf('text/') === 0 .startsWith('text/')
) { ) {
return response.text(); return response.text();
} else { } else {

View File

@ -58,15 +58,15 @@ export abstract class JellyfinApi {
}; };
if (this.accessToken) { if (this.accessToken) {
parameters['Token'] = this.accessToken; parameters.Token = this.accessToken;
} }
if (this.deviceId) { if (this.deviceId) {
parameters['DeviceId'] = this.deviceId; parameters.DeviceId = this.deviceId;
} }
if (this.deviceName) { if (this.deviceName) {
parameters['Device'] = this.deviceName; parameters.Device = this.deviceName;
} }
let header = 'MediaBrowser'; let header = 'MediaBrowser';
@ -93,7 +93,7 @@ export abstract class JellyfinApi {
} }
// Remove leading slashes // Remove leading slashes
while (path.charAt(0) === '/') { while (path.startsWith('/')) {
path = path.substring(1); path = path.substring(1);
} }
@ -104,7 +104,7 @@ export abstract class JellyfinApi {
public static createUserUrl(path: string | null = null): string { public static createUserUrl(path: string | null = null): string {
if (path) { if (path) {
// Remove leading slashes // Remove leading slashes
while (path.charAt(0) === '/') { while (path.startsWith('/')) {
path = path.substring(1); path = path.substring(1);
} }

View File

@ -414,11 +414,7 @@ export function setSubtitleStreamIndex(
const mediaStreams = state.PlaybackMediaSource?.MediaStreams; const mediaStreams = state.PlaybackMediaSource?.MediaStreams;
const subtitleStream = getStreamByIndex( const subtitleStream = getStreamByIndex(mediaStreams!, 'Subtitle', index);
mediaStreams as MediaStream[],
'Subtitle',
index
);
if (!subtitleStream) { if (!subtitleStream) {
console.log( console.log(
@ -738,8 +734,7 @@ export function checkDirectPlay(mediaSource: MediaSourceInfo): void {
if ( if (
mediaSource.SupportsDirectPlay && mediaSource.SupportsDirectPlay &&
mediaSource.Protocol == 'Http' && mediaSource.Protocol == 'Http' &&
(!mediaSource.RequiredHttpHeaders || !mediaSource.RequiredHttpHeaders?.length
!mediaSource.RequiredHttpHeaders.length)
) { ) {
return; return;
} }
@ -771,7 +766,7 @@ export function setTextTrack(index: number | null): void {
} }
); );
if (subtitleTrack && subtitleTrack.trackId !== undefined) { if (subtitleTrack?.trackId !== undefined) {
textTracksManager.setActiveByIds([subtitleTrack.trackId]); textTracksManager.setActiveByIds([subtitleTrack.trackId]);
const subtitleAppearance = window.subtitleAppearance; const subtitleAppearance = window.subtitleAppearance;

View File

@ -129,13 +129,10 @@ export function getSenderReportingData(
nowPlayingItem.PrimaryImageTag = item.AlbumPrimaryImageTag; nowPlayingItem.PrimaryImageTag = item.AlbumPrimaryImageTag;
} }
if (item.BackdropImageTags && item.BackdropImageTags.length) { if (item.BackdropImageTags?.length) {
nowPlayingItem.BackdropItemId = item.Id; nowPlayingItem.BackdropItemId = item.Id;
nowPlayingItem.BackdropImageTag = item.BackdropImageTags[0]; nowPlayingItem.BackdropImageTag = item.BackdropImageTags[0];
} else if ( } else if (item.ParentBackdropImageTags?.length) {
item.ParentBackdropImageTags &&
item.ParentBackdropImageTags.length
) {
nowPlayingItem.BackdropItemId = item.ParentBackdropItemId; nowPlayingItem.BackdropItemId = item.ParentBackdropItemId;
nowPlayingItem.BackdropImageTag = item.ParentBackdropImageTags[0]; nowPlayingItem.BackdropImageTag = item.ParentBackdropImageTags[0];
} }
@ -219,8 +216,7 @@ export function getMetadata(item: BaseItemDto): any {
} else if (item.Type == 'Audio') { } else if (item.Type == 'Audio') {
metadata = new cast.framework.messages.MusicTrackMediaMetadata(); metadata = new cast.framework.messages.MusicTrackMediaMetadata();
metadata.songName = item.Name; metadata.songName = item.Name;
metadata.artist = metadata.artist = item.Artists?.length ? item.Artists.join(', ') : '';
item.Artists && item.Artists.length ? item.Artists.join(', ') : '';
metadata.albumArtist = item.AlbumArtist; metadata.albumArtist = item.AlbumArtist;
metadata.albumName = item.Album; metadata.albumName = item.Album;
@ -263,7 +259,7 @@ export function getMetadata(item: BaseItemDto): any {
).toISOString(); ).toISOString();
} }
if (item.Studios && item.Studios.length) { if (item.Studios?.length) {
metadata.studio = item.Studios[0]; metadata.studio = item.Studios[0];
} }
} }
@ -329,9 +325,7 @@ export function createStreamInfo(
playerStartPositionTicks = startPosition || 0; playerStartPositionTicks = startPosition || 0;
} else { } else {
// TODO deal with !TranscodingUrl // TODO deal with !TranscodingUrl
mediaUrl = JellyfinApi.createUrl( mediaUrl = JellyfinApi.createUrl(mediaSource.TranscodingUrl!);
mediaSource.TranscodingUrl as string
);
if (isHlsStream(mediaSource)) { if (isHlsStream(mediaSource)) {
mediaUrl += seekParam; mediaUrl += seekParam;
@ -342,9 +336,7 @@ export function createStreamInfo(
contentType = `video/${mediaSource.TranscodingContainer}`; contentType = `video/${mediaSource.TranscodingContainer}`;
streamContainer = mediaSource.TranscodingContainer; streamContainer = mediaSource.TranscodingContainer;
if ( if (mediaUrl.toLowerCase().includes('copytimestamps=true')) {
mediaUrl.toLowerCase().indexOf('copytimestamps=true') != -1
) {
startPosition = 0; startPosition = 0;
} }
} }
@ -373,9 +365,7 @@ export function createStreamInfo(
contentType = `audio/${mediaSource.TranscodingContainer}`; contentType = `audio/${mediaSource.TranscodingContainer}`;
// TODO deal with !TranscodingUrl // TODO deal with !TranscodingUrl
mediaUrl = JellyfinApi.createUrl( mediaUrl = JellyfinApi.createUrl(mediaSource.TranscodingUrl!);
mediaSource.TranscodingUrl as string
);
} }
} }
} }