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

View File

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

View File

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

View File

@ -414,11 +414,7 @@ export function setSubtitleStreamIndex(
const mediaStreams = state.PlaybackMediaSource?.MediaStreams;
const subtitleStream = getStreamByIndex(
mediaStreams as MediaStream[],
'Subtitle',
index
);
const subtitleStream = getStreamByIndex(mediaStreams!, 'Subtitle', index);
if (!subtitleStream) {
console.log(
@ -738,8 +734,7 @@ export function checkDirectPlay(mediaSource: MediaSourceInfo): void {
if (
mediaSource.SupportsDirectPlay &&
mediaSource.Protocol == 'Http' &&
(!mediaSource.RequiredHttpHeaders ||
!mediaSource.RequiredHttpHeaders.length)
!mediaSource.RequiredHttpHeaders?.length
) {
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]);
const subtitleAppearance = window.subtitleAppearance;

View File

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