feat: stop music for playbacks
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
import { icons } from '../../assets'
|
||||
import { projectsRef } from '../../config/firebase'
|
||||
import useDataFromRef from '../../hooks/useDataFromRef'
|
||||
import usePlayer from '../../hooks/usePlayer'
|
||||
import { useUser } from '../../providers/UserDataProvider'
|
||||
import { Palette } from '../../styles'
|
||||
import { FONT_FAMILY } from '../../styles/Fonts'
|
||||
@@ -22,6 +23,8 @@ const Playbacks = () => {
|
||||
const { height: windowHeight } = useWindowDimensions()
|
||||
const [activeIndex, setActiveIndex] = useState(0)
|
||||
const route = useRoute()
|
||||
const { stop } = usePlayer() || {}
|
||||
const wasFocusedRef = useRef(false)
|
||||
const initialFocusProjectId = route?.params?.projectId || route?.params?.focusId || null
|
||||
const [focusProjectId, setFocusProjectId] = useState(initialFocusProjectId)
|
||||
const [viewMode, setViewMode] = useState(initialFocusProjectId ? 'feed' : 'charts')
|
||||
@@ -60,6 +63,13 @@ const Playbacks = () => {
|
||||
const backgroundSeekPendingRef = useRef(false)
|
||||
const listRef = useRef(null)
|
||||
|
||||
useEffect(() => {
|
||||
if (isFocused && !wasFocusedRef.current) {
|
||||
stop?.().catch(() => {})
|
||||
}
|
||||
wasFocusedRef.current = isFocused
|
||||
}, [isFocused, stop])
|
||||
|
||||
useEffect(() => {
|
||||
const total = playbacks?.length || 0
|
||||
if (total <= 0) {
|
||||
|
||||
Reference in New Issue
Block a user