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

Commit

Permalink
Fix profile clearing (#1908)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers committed Sep 13, 2022
1 parent 75e6eec commit a27c976
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// @ts-nocheck
// TODO(nkang) - convert to TS
import { LineupActions } from '../../../../../store/lineup/actions'
import { LineupActions } from '../../../../lineup/actions'

export const PREFIX = 'PROFILE_TRACKS'

Expand Down
20 changes: 11 additions & 9 deletions packages/mobile/src/screens/profile-screen/ProfileScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
profilePageFeedLineupActions as feedActions
} from '@audius/common'
import { PortalHost } from '@gorhom/portal'
import { useFocusEffect } from '@react-navigation/native'
import { Animated, View } from 'react-native'
import { useDispatch, useSelector } from 'react-redux'

Expand All @@ -31,8 +32,6 @@ import { ProfileTabNavigator } from './ProfileTabNavigator'
import { useSelectProfile } from './selectors'
const { requestOpen: requestOpenShareModal } = shareModalUIActions
const { fetchProfile: fetchProfileAction, resetProfile } = profilePageActions
const { reset: resetTracks } = tracksActions
const { reset: resetFeed } = feedActions
const { getProfileStatus } = profilePageSelectors
const getUserId = accountSelectors.getUserId

Expand Down Expand Up @@ -71,15 +70,18 @@ export const ProfileScreen = () => {
[dispatch, handle, user_id]
)

useEffect(() => {
const clearProfile = useCallback(() => {
dispatch(resetProfile())
dispatch(tracksActions.reset())
dispatch(feedActions.reset())
}, [dispatch])

const handleLoadProfile = useCallback(() => {
fetchProfile()
return clearProfile
}, [fetchProfile, clearProfile])

return () => {
dispatch(resetProfile())
dispatch(resetTracks())
dispatch(resetFeed())
}
}, [dispatch, fetchProfile])
useFocusEffect(handleLoadProfile)

const handleRefresh = useCallback(() => {
if (profile) {
Expand Down

0 comments on commit a27c976

Please sign in to comment.