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

Commit

Permalink
[C-1020] Remove web pushes (#1902)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers committed Sep 12, 2022
1 parent 600f673 commit d21d5d4
Show file tree
Hide file tree
Showing 73 changed files with 167 additions and 602 deletions.
13 changes: 3 additions & 10 deletions packages/mobile/src/components/artist-card/ArtistCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,15 @@ const formatProfileCardSecondaryText = (followers: number) => {

type ArtistCardProps = {
artist: User
/**
* Optional source page that establishes the `fromPage` for web-routes.
*/
fromPage?: string
style?: StyleProp<ViewStyle>
}

export const ArtistCard = ({ artist, fromPage, style }: ArtistCardProps) => {
export const ArtistCard = ({ artist, style }: ArtistCardProps) => {
const { handle } = artist
const navigation = useNavigation()
const handlePress = useCallback(() => {
navigation.push({
native: { screen: 'Profile', params: { handle } },
web: { route: handle, fromPage }
})
}, [navigation, handle, fromPage])
navigation.push('Profile', { handle })
}, [navigation, handle])

return (
<Card
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ export const ChallengeRewardsDrawerProvider = () => {

const handleNavigation = useCallback(() => {
if (config.buttonInfo?.navigation) {
navigate(config.buttonInfo.navigation)
const { screen, params } = config.buttonInfo.navigation
navigate(screen, params)
handleClose()
}
}, [navigate, config, handleClose])
Expand Down
19 changes: 3 additions & 16 deletions packages/mobile/src/components/collection-card/CollectionCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type { StyleProp, ViewStyle } from 'react-native'
import { Card } from 'app/components/card'
import { useNavigation } from 'app/hooks/useNavigation'
import { formatCount } from 'app/utils/format'
import { getCollectionRoute } from 'app/utils/routes'

const formatPlaylistCardSecondaryText = (saves: number, tracks: number) => {
const savesText = saves === 1 ? 'Favorite' : 'Favorites'
Expand All @@ -16,26 +15,14 @@ const formatPlaylistCardSecondaryText = (saves: number, tracks: number) => {

type CollectionCardProps = {
collection: UserCollection
/**
* Optional source page that establishes the `fromPage` for web-routes.
*/
fromPage?: string
style?: StyleProp<ViewStyle>
}

export const CollectionCard = ({
collection,
fromPage,
style
}: CollectionCardProps) => {
export const CollectionCard = ({ collection, style }: CollectionCardProps) => {
const navigation = useNavigation()
const handlePress = useCallback(() => {
const collectionRoute = getCollectionRoute(collection)
navigation.push({
native: { screen: 'Collection', params: { id: collection.playlist_id } },
web: { route: collectionRoute, fromPage }
})
}, [navigation, collection, fromPage])
navigation.push('Collection', { id: collection.playlist_id })
}, [navigation, collection])

return (
<Card
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,14 @@ type ListProps = Omit<

type CollectionListProps = {
collection: UserCollection[]
fromPage?: string
} & ListProps

export const CollectionList = (props: CollectionListProps) => {
const { collection, fromPage, ...other } = props
const { collection, ...other } = props
return (
<CardList
data={collection}
renderItem={({ item }) => (
<CollectionCard collection={item} fromPage={fromPage} />
)}
renderItem={({ item }) => <CollectionCard collection={item} />}
{...other}
/>
)
Expand Down
5 changes: 1 addition & 4 deletions packages/mobile/src/components/details-tile/DetailsTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,10 +195,7 @@ export const DetailsTile = ({
if (!user) {
return
}
navigation.push({
native: { screen: 'Profile', params: { handle: user.handle } },
web: { route: `/${user.handle}` }
})
navigation.push('Profile', { handle: user.handle })
}, [navigation, user])

const detailLabels = details.filter(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCallback } from 'react'
// on settings page and it doesn't necessarily make sense in common
import { settingsPageActions, PushNotificationSetting } from '@audius/common'
import { StyleSheet, View } from 'react-native'
import { useDispatch } from 'react-redux'

import IconCoSign from 'app/assets/images/iconCoSign.svg'
import IconFollow from 'app/assets/images/iconFollow.svg'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { useCallback } from 'react'

import type { User } from '@audius/common'
import { profilePage } from 'audius-client/src/utils/route'
import { View } from 'react-native'
import { TouchableOpacity } from 'react-native-gesture-handler'

Expand Down Expand Up @@ -53,10 +52,7 @@ export const ReceiverDetails = ({ receiver }: ReceiverDetailsProps) => {
const navigation = useNavigation()

const goToReceiverProfile = useCallback(() => {
navigation.navigate({
native: { screen: 'Profile', params: { handle: receiver.handle } },
web: { route: profilePage(receiver.handle) }
})
navigation.navigate('Profile', { handle: receiver.handle })
}, [navigation, receiver])

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const SendTipButton = ({ receiver }: SendTipButtonProps) => {

const handlePress = useCallback(() => {
dispatch(beginTip({ user: receiver, source: 'feed' }))
navigation.navigate({ native: { screen: 'TipArtist' } })
navigation.navigate('TipArtist')
}, [dispatch, receiver, navigation])

const handlePressIn = useCallback(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,9 @@ export const SenderDetails = ({ senders, receiver }: SenderDetailsProps) => {
const navigation = useNavigation()

const handlePressTippers = useCallback(() => {
navigation.push({
native: {
screen: 'TopSupporters',
params: { userId: receiver.user_id, source: 'feed' }
}
navigation.push('TopSupporters', {
userId: receiver.user_id,
source: 'feed'
})
}, [navigation, receiver])

Expand Down
18 changes: 2 additions & 16 deletions packages/mobile/src/components/lineup-tile/CollectionTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
shareModalUIActions,
RepostType
} from '@audius/common'
import { albumPage, playlistPage } from 'audius-client/src/utils/route'
import { useDispatch, useSelector } from 'react-redux'

import { useCollectionCoverArt } from 'app/hooks/useCollectionCoverArt'
Expand Down Expand Up @@ -120,16 +119,6 @@ const CollectionTileComponent = ({
size: SquareSizes.SIZE_150_BY_150
})

const routeWeb = useMemo(() => {
return collection.is_album
? albumPage(user.handle, collection.playlist_name, collection.playlist_id)
: playlistPage(
user.handle,
collection.playlist_name,
collection.playlist_id
)
}, [collection, user])

const handlePress = useCallback(
({ isPlaying }) => {
if (!tracks.length) return
Expand All @@ -146,11 +135,8 @@ const CollectionTileComponent = ({
)

const handlePressTitle = useCallback(() => {
navigation.push({
native: { screen: 'Collection', params: { id: playlist_id } },
web: { route: routeWeb }
})
}, [playlist_id, routeWeb, navigation])
navigation.push('Collection', { id: playlist_id })
}, [playlist_id, navigation])

const duration = useMemo(() => {
return tracks.reduce(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,7 @@ export const LineupTileMetadata = ({
const { primary } = useThemeColors()

const handleArtistPress = useCallback(() => {
navigation.push({
native: { screen: 'Profile', params: { handle: user.handle } },
web: { route: `/${user.handle}` }
})
navigation.push('Profile', { handle: user.handle })
}, [navigation, user])

return (
Expand Down
17 changes: 2 additions & 15 deletions packages/mobile/src/components/lineup-tile/LineupTileStats.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import {
repostsUserListActions,
favoritesUserListActions
} from '@audius/common'
import {
FAVORITING_USERS_ROUTE,
REPOSTING_USERS_ROUTE
} from 'audius-client/src/utils/route'
import { View, Pressable, StyleSheet } from 'react-native'
import { useDispatch } from 'react-redux'

Expand Down Expand Up @@ -106,21 +102,12 @@ export const LineupTileStats = ({

const handlePressFavorites = useCallback(() => {
dispatch(setFavorite(id, favoriteType))
navigation.push({
native: { screen: 'Favorited', params: { id, favoriteType } },
web: { route: FAVORITING_USERS_ROUTE }
})
navigation.push('Favorited', { id, favoriteType })
}, [dispatch, id, navigation, favoriteType])

const handlePressReposts = useCallback(() => {
dispatch(setRepost(id, repostType))
navigation.push({
native: {
screen: 'Reposts',
params: { id, repostType }
},
web: { route: REPOSTING_USERS_ROUTE }
})
navigation.push('Reposts', { id, repostType })
}, [dispatch, id, navigation, repostType])

return (
Expand Down
8 changes: 2 additions & 6 deletions packages/mobile/src/components/lineup-tile/TrackTile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ const TrackTileComponent = ({
is_unlisted,
has_current_user_reposted,
has_current_user_saved,
permalink,
play_count,
title,
track_id
Expand Down Expand Up @@ -112,11 +111,8 @@ const TrackTileComponent = ({
)

const handlePressTitle = useCallback(() => {
navigation.push({
native: { screen: 'Track', params: { id: track_id } },
web: { route: permalink }
})
}, [navigation, permalink, track_id])
navigation.push('Track', { id: track_id })
}, [navigation, track_id])

const handlePressOverflow = useCallback(() => {
if (track_id === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,15 @@ const NowPlayingDrawer = ({ translationAnim }: NowPlayingDrawerProps) => {
if (!user) {
return
}
navigation.push({
native: { screen: 'Profile', params: { handle: user.handle } },
web: { route: `/${user.handle}` }
})
navigation.push('Profile', { handle: user.handle })
handleDrawerCloseFromSwipe()
}, [handleDrawerCloseFromSwipe, navigation, user])

const handlePressTitle = useCallback(() => {
if (!track) {
return
}
navigation.push({
native: { screen: 'Track', params: { id: track.track_id } },
web: { route: track.permalink }
})
navigation.push('Track', { id: track.track_id })
handleDrawerCloseFromSwipe()
}, [handleDrawerCloseFromSwipe, navigation, track])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@ import {
OverflowAction,
mobileOverflowMenuUISelectors
} from '@audius/common'
// Importing directly from audius-client for now, this will be removed
// when the profile page is implemented in RN
import {
profilePage,
playlistPage,
albumPage
} from 'audius-client/src/utils/route'
import { useDispatch, useSelector } from 'react-redux'

import { useNavigation } from 'app/hooks/useNavigation'
Expand Down Expand Up @@ -75,27 +68,13 @@ const CollectionOverflowMenuDrawer = ({ render }: Props) => {
[OverflowAction.SHARE]: () =>
dispatch(shareCollection(id, ShareSource.OVERFLOW)),
[OverflowAction.VIEW_ALBUM_PAGE]: () => {
navigation.navigate({
native: { screen: 'Collection', params: { id } },
web: {
route: (is_album ? albumPage : playlistPage)(
handle,
playlist_name,
id
)
}
})
navigation.navigate('Collection', { id })
},
[OverflowAction.VIEW_ARTIST_PAGE]: () => {
navigation.navigate({
native: { screen: 'Profile', params: { handle } },
web: { route: profilePage(handle) }
})
navigation.navigate('Profile', { handle })
},
[OverflowAction.EDIT_PLAYLIST]: () => {
navigation.navigate({
native: { screen: 'EditPlaylist', params: { id } }
})
navigation.navigate('EditPlaylist', { id })
dispatch(openEditPlaylist(id))
},
[OverflowAction.DELETE_PLAYLIST]: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import {
OverflowAction,
mobileOverflowMenuUISelectors
} from '@audius/common'
// Importing directly from audius-client for now, this will be removed
// when the profile page is implemented in RN
import { profilePage } from 'audius-client/src/utils/route'
import { useDispatch, useSelector } from 'react-redux'

import { useDrawer } from 'app/hooks/useDrawer'
Expand Down Expand Up @@ -47,7 +44,7 @@ const TrackOverflowMenuDrawer = ({ render }: Props) => {
if (!track || !user) {
return null
}
const { owner_id, title, permalink } = track
const { owner_id, title } = track
const { handle } = user

if (!id || !owner_id || !handle || !title) {
Expand All @@ -69,17 +66,11 @@ const TrackOverflowMenuDrawer = ({ render }: Props) => {
dispatch(openAddToPlaylistModal(id, title)),
[OverflowAction.VIEW_TRACK_PAGE]: () => {
closeNowPlayingDrawer()
navigation.navigate({
native: { screen: 'Track', params: { id } },
web: { route: permalink }
})
navigation.navigate('Track', { id })
},
[OverflowAction.VIEW_ARTIST_PAGE]: () => {
closeNowPlayingDrawer()
navigation.navigate({
native: { screen: 'Profile', params: { handle } },
web: { route: profilePage(handle) }
})
navigation.navigate('Profile', { handle })
},
[OverflowAction.FOLLOW_ARTIST]: () =>
dispatch(followUser(owner_id, FollowSource.OVERFLOW)),
Expand Down

0 comments on commit d21d5d4

Please sign in to comment.