Bluesky app fork with some witchin' additions 💫

[Video] Fix crash when switching tabs (#4925)

authored by hailey.at and committed by

GitHub 99d1a881 134fcd35

+4 -19
+4 -19
src/view/com/util/post-embeds/VideoEmbedInner/VideoEmbedInnerNative.tsx
··· 23 23 const ref = useRef<VideoView>(null) 24 24 const isScreenFocused = useIsFocused() 25 25 const isAppFocused = useAppState() 26 - const prevFocusedRef = useRef(isAppFocused) 27 26 28 - // resume video when coming back from background 29 27 useEffect(() => { 30 - if (isAppFocused !== prevFocusedRef.current) { 31 - prevFocusedRef.current = isAppFocused 32 - if (isAppFocused === 'active') { 33 - player.play() 34 - } 35 - } 36 - }, [isAppFocused, player]) 37 - 38 - // pause the video when the screen is not focused 39 - useEffect(() => { 40 - if (!isScreenFocused) { 41 - let wasPlaying = player.playing 28 + if (isAppFocused === 'active' && isScreenFocused && !player.playing) { 29 + player.play() 30 + } else if (player.playing) { 42 31 player.pause() 43 - 44 - return () => { 45 - if (wasPlaying) player.play() 46 - } 47 32 } 48 - }, [isScreenFocused, player]) 33 + }, [isAppFocused, player, isScreenFocused]) 49 34 50 35 const enterFullscreen = useCallback(() => { 51 36 ref.current?.enterFullscreen()