Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

Commit

Permalink
[PAY-1412] Reset player state on app load (#3632)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored Jun 21, 2023
1 parent 965330c commit d1aee10
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/mobile/src/screens/root-screen/RootScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import { useCallback, useEffect, useState } from 'react'

import { accountSelectors, chatActions, Status } from '@audius/common'
import {
accountSelectors,
chatActions,
playerActions,
Status
} from '@audius/common'
import type { NavigatorScreenParams } from '@react-navigation/native'
import { createNativeStackNavigator } from '@react-navigation/native-stack'
import { getHasCompletedAccount } from 'common/store/pages/signon/selectors'
Expand All @@ -24,6 +29,7 @@ import { StatusBar } from './StatusBar'
const { getAccountStatus } = accountSelectors
const { fetchMoreChats, fetchUnreadMessagesCount, connect, disconnect } =
chatActions
const { reset } = playerActions

export type RootScreenParamList = {
HomeStack: NavigatorScreenParams<{
Expand Down Expand Up @@ -61,9 +67,12 @@ export const RootScreen = ({
!isLoaded &&
(accountStatus === Status.SUCCESS || accountStatus === Status.ERROR)
) {
// Reset the player when the app is loaded for the first time. Fixes an issue
// where after a crash, the player would persist the previous state. PAY-1412.
dispatch(reset({ shouldAutoplay: false }))
setIsLoaded(true)
}
}, [accountStatus, setIsLoaded, isLoaded])
}, [accountStatus, setIsLoaded, isLoaded, dispatch])

// Connect to chats websockets and prefetch chats
useEffect(() => {
Expand Down

0 comments on commit d1aee10

Please sign in to comment.