fix: (beta) file-show: auto-play's unwanted "next" action
Massimo Melina committed
Feb 16, 2024 at 12:15 UTC
faf84d78d6a6311a95e1f8ff080c5010cc3435d4
1 file changed
+2
-2
frontend/src/show.ts
+2
-2
@@ -72,8 +72,8 @@ export function fileShow(entry: DirEntry, { startPlaying=false } = {}) {
72
73
const { auto_play_seconds } = useSnapState()
74
const [autoPlaying, setAutoPlaying] = useState(startPlaying)
75
- const showElement = containerRef.current?.querySelector('.showing')
75
useEffect(() => {
76
+ const showElement = containerRef.current?.querySelector('.showing') // like this, we don't require component to forward ref (easier for plugins)
77
if (!autoPlaying || !showElement) return
78
if (showElement instanceof HTMLMediaElement) {
79
showElement.play().catch(curFailed)
@@ -82,7 +82,7 @@ export function fileShow(entry: DirEntry, { startPlaying=false } = {}) {
82
// we are supposedly showing an image
83
const h = setTimeout(goNext, state.auto_play_seconds * 1000)
84
return () => clearTimeout(h)
85
- }, [showElement, autoPlaying, cur])
85
+ }, [autoPlaying, cur])
86
const {mediaSession} = navigator
87
mediaSession.setActionHandler('nexttrack', goNext)
88
mediaSession.setActionHandler('previoustrack', goPrev)