Skip to content

Commit

Permalink
[PAY-2872] Mobile purchase notifications navigate to content (#8480)
Browse files Browse the repository at this point in the history
  • Loading branch information
dharit-tan authored May 15, 2024
1 parent 2b9d03d commit 5bc505a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 16 deletions.
12 changes: 10 additions & 2 deletions packages/mobile/src/hooks/useNotificationNavigation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ import type {
AddTrackToPlaylistNotification,
AddTrackToPlaylistPushNotification,
MessagePushNotification,
MessageReactionPushNotification
MessageReactionPushNotification,
USDCPurchaseBuyerNotification,
USDCPurchaseSellerNotification
} from '@audius/common/store'
import {
NotificationType,
Expand Down Expand Up @@ -103,7 +105,11 @@ export const useNotificationNavigation = () => {

const entityHandler = useCallback(
(
notification: RepostOfRepostNotification | FavoriteOfRepostNotification
notification:
| RepostOfRepostNotification
| FavoriteOfRepostNotification
| USDCPurchaseBuyerNotification
| USDCPurchaseSellerNotification
) => {
const { entityType, entityId } = notification
if (entityType === Entity.Track) {
Expand Down Expand Up @@ -294,6 +300,8 @@ export const useNotificationNavigation = () => {
}
},
[NotificationType.Tastemaker]: entityHandler,
[NotificationType.USDCPurchaseBuyer]: entityHandler,
[NotificationType.USDCPurchaseSeller]: entityHandler,
[PushNotificationType.Message]: messagesHandler,
[PushNotificationType.MessageReaction]: messagesHandler
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { notificationsSelectors } from '@audius/common/store'
import { View } from 'react-native'

import { IconStars } from '@audius/harmony-native'
import { useNotificationNavigation } from 'app/hooks/useNotificationNavigation'
import { useNavigation } from 'app/hooks/useNavigation'

import {
NotificationHeader,
Expand All @@ -32,7 +32,7 @@ export const TrackAddedToPurchasedAlbumNotification = (
props: TrackAddedToPurchasedAlbumNotificationProps
) => {
const { notification } = props
const navigation = useNotificationNavigation()
const navigation = useNavigation()
const entities = useProxySelector(
(state) => getNotificationEntities(state, notification),
[notification]
Expand All @@ -41,10 +41,11 @@ export const TrackAddedToPurchasedAlbumNotification = (
const playlistOwner = playlist.user

const handlePress = useCallback(() => {
if (playlist) {
navigation.navigate(notification)
}
}, [playlist, navigation, notification])
navigation.navigate('Collection', {
id: playlist.playlist_id,
canBeUnlisted: false
})
}, [navigation, playlist.playlist_id])

if (!playlistOwner || !track || !playlist) return null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ export const USDCPurchaseBuyerNotification = ({
)

const handlePress = useCallback(() => {
if (content) {
navigation.navigate(notification)
}
}, [content, navigation, notification])
navigation.navigate(notification)
}, [navigation, notification])

if (!content || !sellerUser) return null
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ export const USDCPurchaseSellerNotification = (
const { amount, extraAmount } = notification

const handlePress = useCallback(() => {
if (content) {
navigation.navigate(notification)
}
}, [content, navigation, notification])
navigation.navigate(notification)
}, [navigation, notification])

if (!content || !buyerUser) return null
return (
Expand Down

0 comments on commit 5bc505a

Please sign in to comment.