Merge pull request #665 from 3flex/playrequest-typing

Add PlayRequest typing
This commit is contained in:
Niels van Velzen 2024-11-03 09:44:51 +01:00 committed by GitHub
commit aa84761cf9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 9 deletions

View File

@ -593,13 +593,12 @@ export async function translateItems(
export async function instantMix( export async function instantMix(
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any, data: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any options: PlayRequest,
options: any,
item: BaseItemDto item: BaseItemDto
): Promise<void> { ): Promise<void> {
const result = await getInstantMixItems(data.userId, item); const result = await getInstantMixItems(data.userId, item);
options.items = result.Items; options.items = result.Items ?? [];
PlaybackManager.playFromOptions(data.options); PlaybackManager.playFromOptions(data.options);
} }
@ -613,13 +612,12 @@ export async function instantMix(
export async function shuffle( export async function shuffle(
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any, data: any,
// eslint-disable-next-line @typescript-eslint/no-explicit-any options: PlayRequest,
options: any,
item: BaseItemDto item: BaseItemDto
): Promise<void> { ): Promise<void> {
const result = await getShuffleItems(data.userId, item); const result = await getShuffleItems(data.userId, item);
options.items = result.Items; options.items = result.Items ?? [];
PlaybackManager.playFromOptions(data.options); PlaybackManager.playFromOptions(data.options);
} }

View File

@ -26,7 +26,7 @@ import {
checkDirectPlay, checkDirectPlay,
createMediaInformation createMediaInformation
} from './maincontroller'; } from './maincontroller';
import { ItemIndex } from '~/types/global'; import { ItemIndex, PlayRequest } from '~/types/global';
export interface PlaybackState { export interface PlaybackState {
startPositionTicks: number; startPositionTicks: number;
@ -104,8 +104,7 @@ export abstract class PlaybackManager {
); );
} }
// eslint-disable-next-line @typescript-eslint/no-explicit-any static async playFromOptions(options: PlayRequest): Promise<void> {
static async playFromOptions(options: any): Promise<void> {
const firstItem = options.items[0]; const firstItem = options.items[0];
if (options.startPositionTicks || firstItem.MediaType !== 'Video') { if (options.startPositionTicks || firstItem.MediaType !== 'Video') {