Skip to content

Commit

Permalink
chore: fix hook deps
Browse files Browse the repository at this point in the history
  • Loading branch information
ambar committed Mar 9, 2022
1 parent 9adcf32 commit ec8c661
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions packages/griffith/src/components/Player.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,6 @@ const InnerPlayer: React.FC<InnerPlayerProps> = ({
}
}, [emitEvent, showController])

const preSources = usePrevious(sources)
useEffect(() => {
if (preSources && preSources !== sources) {
handleSeek(0)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sources])

// sync document title
useEffect(() => {
if (
Expand Down Expand Up @@ -491,6 +483,13 @@ const InnerPlayer: React.FC<InnerPlayerProps> = ({
onSeek: handleSeek,
})

const prevSources = usePrevious(sources)
useEffect(() => {
if (prevSources && prevSources !== sources) {
handleSeek(0)
}
}, [handleSeek, prevSources, sources])

const isPip = Boolean(Pip.pictureInPictureElement)
// Safari 会将 pip 状态视为全屏
const isFullScreen = Boolean(BigScreen.element) && !isPip
Expand Down

0 comments on commit ec8c661

Please sign in to comment.