Fix lint issues and improve type safety

This commit is contained in:
Mert Uyanık
2025-10-29 08:40:19 +03:00
parent 4551c030ca
commit f26a76836f
4 changed files with 15 additions and 8 deletions
+6 -2
View File
@@ -1,6 +1,9 @@
import React, { createContext, useContext, useRef, useState, useCallback } from 'react'
import type { PlayerContextValue, VideoState, UIState, PlayerSettings, AudioTrack } from '../types'
type SelectedQuality = PlayerSettings['quality']
type SelectedSubtitle = PlayerSettings['subtitle']
interface PlayerContextType extends PlayerContextValue {
setVideoState: React.Dispatch<React.SetStateAction<VideoState>>
setUIState: React.Dispatch<React.SetStateAction<UIState>>
@@ -8,6 +11,7 @@ interface PlayerContextType extends PlayerContextValue {
const PlayerContext = createContext<PlayerContextType | null>(null)
// eslint-disable-next-line react-refresh/only-export-components
export const usePlayerContext = () => {
const context = useContext(PlayerContext)
if (!context) {
@@ -143,11 +147,11 @@ export const PlayerProvider: React.FC<PlayerProviderProps> = ({
}, [])
// Settings
const setQuality = useCallback((quality: typeof settings.quality) => {
const setQuality = useCallback((quality: SelectedQuality) => {
setSettings((prev) => ({ ...prev, quality }))
}, [])
const setSubtitle = useCallback((subtitle: typeof settings.subtitle) => {
const setSubtitle = useCallback((subtitle: SelectedSubtitle) => {
setSettings((prev) => ({ ...prev, subtitle }))
}, [])