Skip to content

Commit

Permalink
chore: remove no-unused-vars
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar committed Sep 17, 2021
1 parent fef297f commit b3bb134
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 41 deletions.
9 changes: 2 additions & 7 deletions example/src/MP4Page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
import React, {useState, useLayoutEffect, useContext, useEffect} from 'react'
import Player, {
MessageContext,
useMessageContextRef,
ACTIONS,
EVENTS,
} from 'griffith'
import React, {useState, useEffect} from 'react'
import Player, {useMessageContextRef, ACTIONS, EVENTS} from 'griffith'
import {useLocation} from 'react-router-dom'
import Logo from './Logo'
import {logEvent} from './utils'
Expand Down
4 changes: 2 additions & 2 deletions packages/griffith-hls/src/VideoComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,13 @@ export default class VideoComponent extends Component<VideoProps> {
render() {
const {
onRef,
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
currentQuality,
useAutoQuality,
src,
sources,
paused,
/* eslint-enable no-unused-vars */
/* eslint-enable @typescript-eslint/no-unused-vars */
...props
} = this.props
return (
Expand Down
4 changes: 2 additions & 2 deletions packages/griffith-mp4/src/VideoComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export default class Player extends Component<VideoProps> {

render() {
const {
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
src,
onRef,
currentQuality,
Expand All @@ -130,7 +130,7 @@ export default class Player extends Component<VideoProps> {
paused,
onTimeUpdate,
onProgress,
/* eslint-enable no-unused-vars */
/* eslint-enable @typescript-eslint/no-unused-vars */
...props
} = this.props
return (
Expand Down
5 changes: 2 additions & 3 deletions packages/griffith/src/components/Controller.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export type ToggleType = 'button' | 'keyCode' | 'video' | null
type ControllerProps = {
standalone?: boolean
isPlaying?: boolean
duration?: number
duration: number
currentTime: number
volume: number
buffered?: number
Expand Down Expand Up @@ -97,8 +97,7 @@ class Controller extends Component<ControllerProps, State> {
}

shouldComponentUpdate(nextProps: ControllerProps) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return this.props.show || nextProps.show
return this.props.show! || nextProps.show!
}

componentWillUnmount() {
Expand Down
16 changes: 13 additions & 3 deletions packages/griffith/src/components/NormalVideo.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import React from 'react'
import {PlaySource} from '../types'

const NormalVideo = (props: any) => {
type NativeVideoProps = React.HTMLProps<HTMLVideoElement>
type VideoProps = NativeVideoProps & {
paused: boolean
currentQuality: string
useAutoQuality: boolean
sources: PlaySource[]
onRef: (el: HTMLVideoElement | null) => void
}

const NormalVideo: React.FC<VideoProps> = (props) => {
const {
onRef,
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
paused,
currentQuality,
useAutoQuality,
sources,
/* eslint-disable no-unused-vars */
/* eslint-disable @typescript-eslint/no-unused-vars */
...restProps
} = props
return <video {...restProps} ref={onRef} />
Expand Down
2 changes: 1 addition & 1 deletion packages/griffith/src/components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ class InnerPlayer extends Component<InnerPlayerProps, State> {
!isPlaybackStarted && !isNeverPlayed && stateCurrentTime !== 0 // 播放结束,显示「重新播放」状态
this.setState({currentTime})
// TODO 想办法去掉这个实例方法调用
this.videoRef.current!.seek(currentTime)
this.videoRef.current?.seek(currentTime)
if (isPlayEnded) {
this.handlePlay()
}
Expand Down
8 changes: 2 additions & 6 deletions packages/griffith/src/components/Slider.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import React, {Component, MouseEvent} from 'react'
import {
css,
StyleDeclaration,
StyleDeclarationMap,
} from 'aphrodite/no-important'
import React, {Component} from 'react'
import {css, StyleDeclarationMap} from 'aphrodite/no-important'
import clamp from 'lodash/clamp'
import {ProgressDot as ProgressDotType} from '../types'
import ProgressDot, {ProgressDotsProps} from './ProgressDot'
Expand Down
40 changes: 25 additions & 15 deletions packages/griffith/src/components/Video.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ type VideoProps = {
onError: (...args: any[]) => any
onEvent: (name: EVENTS, data?: unknown) => void
currentPlaybackRate: PlaybackRate
useAutoQuality?: boolean
}

class Video extends Component<VideoProps> {
Expand Down Expand Up @@ -383,18 +384,27 @@ class Video extends Component<VideoProps> {
}
}

export default React.forwardRef<any, VideoProps>((props, ref) => (
<VideoSourceContext.Consumer>
{({currentSrc, sources, currentQuality, format, currentPlaybackRate}) => (
<Video
ref={ref}
{...props}
src={currentSrc}
format={format}
sources={sources}
currentQuality={currentQuality}
currentPlaybackRate={currentPlaybackRate}
/>
)}
</VideoSourceContext.Consumer>
))
type InjectedProps =
| 'src'
| 'format'
| 'sources'
| 'currentQuality'
| 'currentPlaybackRate'

export default React.forwardRef<any, Omit<VideoProps, InjectedProps>>(
(props, ref) => (
<VideoSourceContext.Consumer>
{({currentSrc, sources, currentQuality, format, currentPlaybackRate}) => (
<Video
ref={ref}
{...props}
src={currentSrc}
format={format}
sources={sources}
currentQuality={currentQuality}
currentPlaybackRate={currentPlaybackRate}
/>
)}
</VideoSourceContext.Consumer>
)
)
3 changes: 1 addition & 2 deletions packages/griffith/src/contexts/MessageContext.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, {useEffect, useLayoutEffect, useRef} from 'react'
import React, {useLayoutEffect, useRef} from 'react'
import EventEmitter from 'eventemitter3'
import {
ACTIONS,
EVENTS,
ActionParamsMap,
EventParamsMap,
Expand Down

0 comments on commit b3bb134

Please sign in to comment.