diff --git a/packages/common/src/hooks/useShareContent.ts b/packages/common/src/hooks/useShareContent.ts index 39a8e6cb23c..940101a6817 100644 --- a/packages/common/src/hooks/useShareContent.ts +++ b/packages/common/src/hooks/useShareContent.ts @@ -9,7 +9,9 @@ export const useShareContent = ( request: ShareModalRequest | null ): ShareContent | null => { const trackId = - request?.type === 'track' || request?.type === 'contest' + request?.type === 'track' || + request?.type === 'contest' || + request?.type === 'milestone' ? request.trackId : null const profileId = request?.type === 'profile' ? request.profileId : null @@ -36,6 +38,11 @@ export const useShareContent = ( return { type: request.type, track, artist: trackArtist } } + if (request.type === 'milestone') { + if (!track || !trackArtist) return null + return { type: 'milestone', track, artist: trackArtist, stat: request.stat } + } + if (request.type === 'profile') { if (!profile) return null return { type: 'profile', profile } diff --git a/packages/common/src/models/Analytics.ts b/packages/common/src/models/Analytics.ts index 0cd98744430..55a901d2d72 100644 --- a/packages/common/src/models/Analytics.ts +++ b/packages/common/src/models/Analytics.ts @@ -397,7 +397,8 @@ export enum ShareSource { NOW_PLAYING = 'now playing', OVERFLOW = 'overflow', LEFT_NAV = 'left-nav', - UPLOAD = 'upload' + UPLOAD = 'upload', + NOTIFICATION = 'notification' } export enum RepostSource { TILE = 'tile', diff --git a/packages/common/src/store/notifications/types.ts b/packages/common/src/store/notifications/types.ts index d2c4e5b05d3..be388f25a79 100644 --- a/packages/common/src/store/notifications/types.ts +++ b/packages/common/src/store/notifications/types.ts @@ -343,6 +343,9 @@ export type MilestoneListenPushNotification = { entityId: ID slot: number type: PushNotificationType.MilestoneListen + /** Set on pushes that should open the milestone stat card */ + shareCard?: boolean + threshold?: number metadata: { threshold: number entity_type: Entity @@ -362,6 +365,9 @@ export type MilestoneRepostPushNotification = { entityId: ID slot: number type: PushNotificationType.MilestoneRepost + /** Set on pushes that should open the milestone stat card */ + shareCard?: boolean + threshold?: number metadata: { threshold: number entity_type: Entity @@ -381,6 +387,9 @@ export type MilestoneFavoritePushNotification = { entityId: ID slot: number type: PushNotificationType.MilestoneFavorite + /** Set on pushes that should open the milestone stat card */ + shareCard?: boolean + threshold?: number metadata: { threshold: number entity_type: Entity @@ -456,6 +465,9 @@ export type TrendingTrackNotification = BaseNotification & { entityId: ID } +/** Trending pushes carry `shareCard` when tapping should open the stat card */ +export type TrendingPushFields = { shareCard?: boolean } + export type TrendingUndergroundNotification = BaseNotification & { type: NotificationType.TrendingUnderground rank: number diff --git a/packages/common/src/store/ui/share-modal/types.ts b/packages/common/src/store/ui/share-modal/types.ts index bceeb8837f4..81f330b64ad 100644 --- a/packages/common/src/store/ui/share-modal/types.ts +++ b/packages/common/src/store/ui/share-modal/types.ts @@ -11,6 +11,7 @@ export type ShareType = | 'playlist' | 'contest' | 'weeklyRotation' + | 'milestone' type ShareTrackContent = { type: 'track' @@ -61,6 +62,21 @@ type ShareWeeklyRotationContent = { user: User } +export type ShareMilestoneStat = + | { kind: 'listens' | 'reposts' | 'favorites'; count: number } + | { kind: 'trending' | 'underground'; rank: number } + +/** + * A track milestone (play count, trending rank) shared as a stat card. + * Links to the track like a track share. + */ +type ShareMilestoneContent = { + type: 'milestone' + track: Track + artist: User + stat: ShareMilestoneStat +} + export type ShareContent = | ShareTrackContent | ShareContestContent @@ -68,6 +84,7 @@ export type ShareContent = | ShareAlbumContent | SharePlaylistContent | ShareWeeklyRotationContent + | ShareMilestoneContent export type ShareModalRequest = | { type: 'track'; trackId: ID } @@ -75,6 +92,7 @@ export type ShareModalRequest = | { type: 'profile'; profileId: ID } | { type: 'collection'; collectionId: ID } | { type: 'weeklyRotation'; userId: ID } + | { type: 'milestone'; trackId: ID; stat: ShareMilestoneStat } export type ShareModalState = { source: Nullable diff --git a/packages/mobile/src/components/share-drawer/ShareDrawer.tsx b/packages/mobile/src/components/share-drawer/ShareDrawer.tsx index 281405172f8..d6bd190da70 100644 --- a/packages/mobile/src/components/share-drawer/ShareDrawer.tsx +++ b/packages/mobile/src/components/share-drawer/ShareDrawer.tsx @@ -42,7 +42,7 @@ import { Text } from '../core' import { ShareToStorySticker } from './ShareToStorySticker' import { messages } from './messages' import { useShareToStory } from './useShareToStory' -import { getContentUrl, getXShareUrl } from './utils' +import { getContentUrl, getStatHeadline, getXShareUrl } from './utils' const { getShareRequest, getShareSource } = shareModalUISelectors const { shareUser } = usersSocialActions @@ -99,8 +99,10 @@ export const ShareDrawer = NiceModal.create(() => { content?.type === 'track' && accountUserId === content.artist.user_id const shareType = content?.type ?? 'track' - const isStreamGatedTrack = - content?.type === 'track' && content.track.is_stream_gated + // Content whose track can be rendered into a story + const storyContent = + content?.type === 'track' || content?.type === 'milestone' ? content : null + const isStreamGatedTrack = !!storyContent?.track.is_stream_gated const handleShareToDirectMessage = useCallback(async () => { if (!content) return @@ -112,7 +114,7 @@ export const ShareDrawer = NiceModal.create(() => { make({ eventName: Name.CHAT_ENTRY_POINT, source: 'share', - kind: content.type + kind: content.type === 'milestone' ? 'track' : content.type }) ) if (source === ShareSource.NOW_PLAYING) { @@ -178,6 +180,7 @@ export const ShareDrawer = NiceModal.create(() => { if (!source || !content) return switch (content.type) { case 'track': + case 'milestone': dispatch(shareTrack(content.track.track_id, source)) break case 'profile': @@ -215,11 +218,11 @@ export const ShareDrawer = NiceModal.create(() => { // Story sharing renders the track's audio, so skip tracks the API marks // unstreamable (undefined = not populated). const isShareableTrack = - content?.type === 'track' && - !content.track.is_unlisted && - !content.track.is_invalid && - !content.track.is_delete && - content.track.is_streamable !== false && + !!storyContent && + !storyContent.track.is_unlisted && + !storyContent.track.is_invalid && + !storyContent.track.is_delete && + storyContent.track.is_streamable !== false && !isStreamGatedTrack const performActionAndClose = useCallback( @@ -287,7 +290,10 @@ export const ShareDrawer = NiceModal.create(() => { result.push(shareToInstagramStoriesAction) result.push(shareVideoToTiktokAction) result.push(shareToSnapchatAction) - } else if (content?.type === 'weeklyRotation') { + } else if ( + content?.type === 'weeklyRotation' || + content?.type === 'milestone' + ) { // Story/video shares need a single track; X only needs the link. result.push(shareToXAction) } @@ -314,6 +320,7 @@ export const ShareDrawer = NiceModal.create(() => { if (!content) return switch (content.type) { case 'track': + case 'milestone': sendShareAction(content.track.track_id, 'track') break case 'album': @@ -326,8 +333,7 @@ export const ShareDrawer = NiceModal.create(() => { return ( <> - {/* Redundant `content?.type === 'track'` needed to make TS happy */} - {content?.type === 'track' ? ( + {storyContent ? ( { > ) : null} diff --git a/packages/mobile/src/components/share-drawer/ShareToStorySticker.tsx b/packages/mobile/src/components/share-drawer/ShareToStorySticker.tsx index 0c8d19dba15..759a2160006 100644 --- a/packages/mobile/src/components/share-drawer/ShareToStorySticker.tsx +++ b/packages/mobile/src/components/share-drawer/ShareToStorySticker.tsx @@ -38,6 +38,8 @@ type ShareToStoryStickerProps = { * When provided, use this instead of TrackImage so the sticker always has a working image URL for capture. */ artworkSource?: ImageSourcePropType + /** Stat shown above the artwork for milestone cards, e.g. 1,000 / Plays */ + headline?: { value: string; label: string } } const useStyles = makeStyles(({ palette, spacing }) => ({ @@ -49,6 +51,16 @@ const useStyles = makeStyles(({ palette, spacing }) => ({ paddingHorizontal: spacing(3), borderRadius: 8 }, + headline: { + alignItems: 'center', + marginBottom: spacing(3) + }, + headlineValue: { + lineHeight: 64 + }, + headlineLabel: { + letterSpacing: 1 + }, trackImage: { height: 240, width: 240, @@ -89,7 +101,8 @@ export const ShareToStorySticker = ({ style, onLoad, omitLogo = false, - artworkSource + artworkSource, + headline }: ShareToStoryStickerProps) => { const styles = useStyles() @@ -97,6 +110,34 @@ export const ShareToStorySticker = ({ return ( + {headline ? ( + + + {headline.value} + + + {headline.label} + + + ) : null} {artworkSource != null ? ( = { album: 'Album', playlist: 'Playlist', contest: 'Contest', - weeklyRotation: 'Weekly Rotation' + weeklyRotation: 'Weekly Rotation', + milestone: 'Milestone' } export const messages = { @@ -33,6 +34,27 @@ export const messages = { `Check out ${albumName} by ${handle} @audius $AUDIO`, playlistShareText: (playlistName: string, handle: string) => `Check out ${playlistName} by ${handle} @audius $AUDIO`, + milestoneCountLabel: { + listens: 'Plays', + reposts: 'Reposts', + favorites: 'Favorites' + }, + milestoneRankLabel: { + trending: 'On Trending', + underground: 'On Underground Trending' + }, + milestoneCountShareText: ( + title: string, + count: string, + label: string, + handle: string + ) => `${title} by ${handle} just hit ${count} ${label} on @audius $AUDIO`, + milestoneRankShareText: ( + title: string, + rank: number, + label: string, + handle: string + ) => `${title} by ${handle} is #${rank} ${label} on @audius $AUDIO`, weeklyRotationShareText: (handle: string) => `Check out ${handle}'s Weekly Rotation on @audius $AUDIO`, loadingStoryModalTitle: 'Generating Story', diff --git a/packages/mobile/src/components/share-drawer/useShareToStory.tsx b/packages/mobile/src/components/share-drawer/useShareToStory.tsx index f952edd5d6c..80ed1b0ae57 100644 --- a/packages/mobile/src/components/share-drawer/useShareToStory.tsx +++ b/packages/mobile/src/components/share-drawer/useShareToStory.tsx @@ -197,13 +197,14 @@ export const useShareToStory = ({ const [selectedPlatform, setSelectedPlatform] = useState(null) - const trackTitle = - content?.type === 'track' ? content?.track.title : undefined - const artistHandle = - content?.type === 'track' ? content?.artist.handle : undefined + // Track and milestone shares both render a track into the story + const storyContent = + content?.type === 'track' || content?.type === 'milestone' ? content : null + const trackTitle = storyContent?.track.title + const artistHandle = storyContent?.artist.handle const trackImage = useTrackImage({ - trackId: content?.type === 'track' ? content.track.track_id : undefined, + trackId: storyContent?.track.track_id, size: SquareSizes.SIZE_480_BY_480 }) const isStickerImageLoadedRef = useRef(false) @@ -212,7 +213,7 @@ export const useShareToStory = ({ stickerLoadedEventEmitter.emit(STICKER_LOADED_EVENT) }, []) - const trackId = content?.type === 'track' ? content.track.track_id : null + const trackId = storyContent?.track.track_id ?? null // Reset when share content (track) changes so we wait for the new sticker to load useEffect(() => { if (trackId) { @@ -220,7 +221,7 @@ export const useShareToStory = ({ } }, [trackId]) const trackImageUri = - content?.type === 'track' && + storyContent && trackImage && trackImage.source && isImageUriSource(trackImage.source) @@ -367,7 +368,7 @@ export const useShareToStory = ({ async (platform: ShareToStoryPlatform) => { const sdk = await audiusSdk() - if (content?.type === 'track') { + if (storyContent) { if (!(await isAppInstalled(platform))) { toast({ content: messages.shareToStoryAppNotInstalled( @@ -378,8 +379,8 @@ export const useShareToStory = ({ track( make({ eventName: ERROR_EVENT_NAMES_MAP[platform], - title: content.track.title, - artist: content.artist.handle, + title: storyContent.track.title, + artist: storyContent.artist.handle, error: 'App not installed' }) ) @@ -390,8 +391,8 @@ export const useShareToStory = ({ track( make({ eventName: START_EVENT_NAMES_MAP[platform], - title: content.track.title, - artist: content.artist.handle + title: storyContent.track.title, + artist: storyContent.artist.handle }) ) @@ -468,7 +469,7 @@ export const useShareToStory = ({ sdk }) streamMp3Url = await sdk.tracks.getTrackStreamUrl({ - trackId: Id.parse(content.track.track_id), + trackId: Id.parse(storyContent.track.track_id), userId: OptionalId.parse(userId), userSignature: signature, userData: data @@ -482,7 +483,7 @@ export const useShareToStory = ({ `storyVideo-${uuid()}.mp4` ) const audioStartOffsetConfig = - content.track.duration && content.track.duration >= 20 + storyContent.track.duration && storyContent.track.duration >= 20 ? '-ss 10 ' : '' @@ -544,7 +545,7 @@ export const useShareToStory = ({ launch = pasteToSnapchatApp( videoUri, `file://${stickerUri}`, - encodeURI(getTrackRoute(content.track, true)) + encodeURI(getTrackRoute(storyContent.track, true)) ) } else { launch = pasteToTikTokApp(storyVideoPath, platform) @@ -574,8 +575,8 @@ export const useShareToStory = ({ track( make({ eventName: SUCCESS_EVENT_NAMES_MAP[platform], - title: content.track.title, - artist: content.artist.handle + title: storyContent.track.title, + artist: storyContent.artist.handle }) ) @@ -591,7 +592,7 @@ export const useShareToStory = ({ }, [ trackImageUri, - content, + storyContent, toggleProgressDrawer, captureStickerImage, pasteToInstagramApp, @@ -675,7 +676,7 @@ export const useShareToStory = ({ cancelStory, /** Pre-resolved artwork source (mirror fallback applied) for the share sticker. Use this so the sticker always has a working image URL. */ stickerArtworkSource: - content?.type === 'track' && + storyContent && trackImage?.source != null && !trackImage.hasNoArtwork ? trackImage.source diff --git a/packages/mobile/src/components/share-drawer/utils.ts b/packages/mobile/src/components/share-drawer/utils.ts index c16aa037f58..a2408e1febb 100644 --- a/packages/mobile/src/components/share-drawer/utils.ts +++ b/packages/mobile/src/components/share-drawer/utils.ts @@ -1,4 +1,4 @@ -import type { ShareContent } from '@audius/common/store' +import type { ShareContent, ShareMilestoneStat } from '@audius/common/store' import { makeXShareUrl, getXShareHandle } from '@audius/common/utils' import { @@ -11,9 +11,30 @@ import { import { messages } from './messages' +const formatStatCount = (count: number) => count.toLocaleString('en-US') + +export const getStatHeadline = (stat: ShareMilestoneStat) => { + switch (stat.kind) { + case 'listens': + case 'reposts': + case 'favorites': + return { + value: formatStatCount(stat.count), + label: messages.milestoneCountLabel[stat.kind] + } + case 'trending': + case 'underground': + return { + value: `#${stat.rank}`, + label: messages.milestoneRankLabel[stat.kind] + } + } +} + export const getContentUrl = (content: ShareContent) => { switch (content.type) { - case 'track': { + case 'track': + case 'milestone': { const { track } = content return getTrackRoute(track, true) } @@ -81,6 +102,28 @@ export const getXShareText = async (content: ShareContent) => { const { user } = content return messages.weeklyRotationShareText(getXShareHandle(user)) } + case 'milestone': { + const { + track: { title }, + artist, + stat + } = content + const handle = getXShareHandle(artist) + const { value, label } = getStatHeadline(stat) + return stat.kind === 'trending' || stat.kind === 'underground' + ? messages.milestoneRankShareText( + title, + stat.rank, + label.toLowerCase(), + handle + ) + : messages.milestoneCountShareText( + title, + value, + label.toLowerCase(), + handle + ) + } } } diff --git a/packages/mobile/src/hooks/useNotificationNavigation.ts b/packages/mobile/src/hooks/useNotificationNavigation.ts index 32ae1ecd96a..b5d20fb2346 100644 --- a/packages/mobile/src/hooks/useNotificationNavigation.ts +++ b/packages/mobile/src/hooks/useNotificationNavigation.ts @@ -23,6 +23,9 @@ import type { RemixCosignNotification, RemixCosignPushNotification, TrendingTrackNotification, + TrendingUndergroundNotification, + TrendingPushFields, + ShareMilestoneStat, ChallengeRewardNotification, TierChangeNotification, AddTrackToPlaylistNotification, @@ -51,15 +54,19 @@ import type { ArtistRemixContestEndingSoonNotification, ArtistRemixContestSubmissionsNotification } from '@audius/common/store' +import { ShareSource } from '@audius/common/models' +import type { ID } from '@audius/common/models' import { NotificationType, PushNotificationType, Entity, - Achievement + Achievement, + shareModalUIActions } from '@audius/common/store' import { OptionalId } from '@audius/sdk' import { useLinkTo } from '@react-navigation/native' import { useQueryClient } from '@tanstack/react-query' +import { useDispatch } from 'react-redux' import { useNavigation } from './useNavigation' @@ -72,6 +79,22 @@ export const useNotificationNavigation = () => { const navigation = useNavigation() const linkTo = useLinkTo() const queryClient = useQueryClient() + const dispatch = useDispatch() + + // Pushes flagged with shareCard open the stat card over the track + const openShareCard = useCallback( + (trackId: ID, stat: ShareMilestoneStat) => { + dispatch( + shareModalUIActions.requestOpen({ + type: 'milestone', + trackId, + stat, + source: ShareSource.NOTIFICATION + }) + ) + }, + [dispatch] + ) const socialActionHandler = useCallback( ( @@ -197,6 +220,18 @@ export const useNotificationNavigation = () => { trackId: notification.entityId, canBeUnlisted: false }) + if (notification.shareCard && notification.threshold) { + const kind = + notification.type === PushNotificationType.MilestoneListen + ? 'listens' + : notification.type === PushNotificationType.MilestoneRepost + ? 'reposts' + : 'favorites' + openShareCard(notification.entityId, { + kind, + count: notification.threshold + }) + } } else { navigation.navigate('Collection', { id: notification.entityId, @@ -204,7 +239,32 @@ export const useNotificationNavigation = () => { }) } }, - [navigation] + [navigation, openShareCard] + ) + + const trendingHandler = useCallback( + ( + notification: ( + | TrendingTrackNotification + | TrendingUndergroundNotification + ) & + TrendingPushFields + ) => { + navigation.navigate('Track', { + trackId: notification.entityId, + canBeUnlisted: false + }) + if (notification.shareCard && notification.rank) { + openShareCard(notification.entityId, { + kind: + notification.type === NotificationType.TrendingUnderground + ? 'underground' + : 'trending', + rank: notification.rank + }) + } + }, + [navigation, openShareCard] ) const messagesHandler = useCallback( @@ -322,14 +382,8 @@ export const useNotificationNavigation = () => { [NotificationType.TierChange]: (notification: TierChangeNotification) => { navigation.navigate('AudioScreen') }, - [NotificationType.TrendingTrack]: ( - notification: TrendingTrackNotification - ) => { - navigation.navigate('Track', { - trackId: notification.entityId, - canBeUnlisted: false - }) - }, + [NotificationType.TrendingTrack]: trendingHandler, + [NotificationType.TrendingUnderground]: trendingHandler, [NotificationType.UserSubscription]: ( notification: UserSubscriptionNotification ) => { @@ -422,6 +476,7 @@ export const useNotificationNavigation = () => { entityHandler, contestHandler, milestoneHandler, + trendingHandler, userIdHandler, messagesHandler, navigation diff --git a/packages/mobile/src/screens/notifications-screen/Notification/NotificationShareCardButton.tsx b/packages/mobile/src/screens/notifications-screen/Notification/NotificationShareCardButton.tsx new file mode 100644 index 00000000000..af40f46dcb2 --- /dev/null +++ b/packages/mobile/src/screens/notifications-screen/Notification/NotificationShareCardButton.tsx @@ -0,0 +1,58 @@ +import { useCallback } from 'react' + +import { ShareSource } from '@audius/common/models' +import type { ID } from '@audius/common/models' +import type { ShareMilestoneStat } from '@audius/common/store' +import { shareModalUIActions } from '@audius/common/store' +import { useDispatch } from 'react-redux' + +import { Button, IconShare } from '@audius/harmony-native' +import { makeStyles } from 'app/styles' + +const messages = { + share: 'Share' +} + +const useStyles = makeStyles(({ spacing }) => ({ + root: { + marginTop: spacing(4), + alignSelf: 'flex-start' + } +})) + +type NotificationShareCardButtonProps = { + trackId: ID + stat: ShareMilestoneStat +} + +/** Opens the share drawer with a stat card for a track milestone */ +export const NotificationShareCardButton = ({ + trackId, + stat +}: NotificationShareCardButtonProps) => { + const styles = useStyles() + const dispatch = useDispatch() + + const handlePress = useCallback(() => { + dispatch( + shareModalUIActions.requestOpen({ + type: 'milestone', + trackId, + stat, + source: ShareSource.NOTIFICATION + }) + ) + }, [dispatch, trackId, stat]) + + return ( + + ) +} diff --git a/packages/mobile/src/screens/notifications-screen/Notification/index.ts b/packages/mobile/src/screens/notifications-screen/Notification/index.ts index 15f6833caed..2a5c45de333 100644 --- a/packages/mobile/src/screens/notifications-screen/Notification/index.ts +++ b/packages/mobile/src/screens/notifications-screen/Notification/index.ts @@ -10,3 +10,4 @@ export * from './UserNameLink' export * from './EntityLink' export * from './NotificationXButton' export * from './constants' +export * from './NotificationShareCardButton' diff --git a/packages/mobile/src/screens/notifications-screen/Notifications/MilestoneNotification.tsx b/packages/mobile/src/screens/notifications-screen/Notifications/MilestoneNotification.tsx index 0cb9e388512..5630fddfd56 100644 --- a/packages/mobile/src/screens/notifications-screen/Notifications/MilestoneNotification.tsx +++ b/packages/mobile/src/screens/notifications-screen/Notifications/MilestoneNotification.tsx @@ -7,9 +7,10 @@ import { import type { User } from '@audius/common/models' import type { EntityType, - MilestoneNotification as MilestoneNotificationType + MilestoneNotification as MilestoneNotificationType, + ShareMilestoneStat } from '@audius/common/store' -import { Achievement } from '@audius/common/store' +import { Achievement, Entity } from '@audius/common/store' import type { Nullable } from '@audius/common/utils' import { formatCount, isEntityHidden, route } from '@audius/common/utils' @@ -22,6 +23,7 @@ import { NotificationText, NotificationTile, NotificationTitle, + NotificationShareCardButton, NotificationXButton } from '../Notification' import { getEntityRoute } from '../Notification/utils' @@ -84,6 +86,31 @@ const getXShareData = ( } } +const statKinds: Partial> = + { + [Achievement.Listens]: 'listens', + [Achievement.Reposts]: 'reposts', + [Achievement.Favorites]: 'favorites' + } + +// Track milestones get a stat card; collection and follower milestones keep X +const getShareCardStat = ( + notification: MilestoneNotificationType, + entity?: Nullable +): Nullable => { + const kind = statKinds[notification.achievement] + if ( + !kind || + !('entityType' in notification) || + notification.entityType !== Entity.Track || + !entity || + isEntityHidden(entity) + ) { + return null + } + return { kind, count: notification.value } +} + type MilestoneNotificationProps = { notification: MilestoneNotificationType } @@ -127,6 +154,7 @@ export const MilestoneNotification = (props: MilestoneNotificationProps) => { } const { link, text } = getXShareData(notification, entity, user) + const shareCardStat = getShareCardStat(notification, entity) return ( @@ -134,7 +162,12 @@ export const MilestoneNotification = (props: MilestoneNotificationProps) => { {messages.title} {renderBody()} - {link && text ? ( + {shareCardStat ? ( + + ) : link && text ? ( ) : null} diff --git a/packages/mobile/src/screens/notifications-screen/Notifications/TrendingTrackNotification.tsx b/packages/mobile/src/screens/notifications-screen/Notifications/TrendingTrackNotification.tsx index 91768a16780..205ec574cf4 100644 --- a/packages/mobile/src/screens/notifications-screen/Notifications/TrendingTrackNotification.tsx +++ b/packages/mobile/src/screens/notifications-screen/Notifications/TrendingTrackNotification.tsx @@ -1,7 +1,6 @@ import { useCallback } from 'react' import { useNotificationEntity } from '@audius/common/api' -import { Name } from '@audius/common/models' import type { TrackEntity, TrendingTrackNotification as TrendingTrackNotificationType @@ -16,16 +15,14 @@ import { NotificationHeader, NotificationText, NotificationTile, - NotificationTitle, - NotificationXButton + NotificationShareCardButton, + NotificationTitle } from '../Notification' const messages = { title: "You're Trending", is: 'is', trending: 'on Trending right now!', - xShareText: (entityTitle: string) => - `My track ${entityTitle} is trending on @audius! Check it out! $AUDIO` } type TrendingTrackNotificationProps = { @@ -50,7 +47,6 @@ export const TrendingTrackNotification = ( if (!entity) return null - const shareText = messages.xShareText(entity.title) return ( @@ -60,13 +56,9 @@ export const TrendingTrackNotification = ( {messages.is} #{rank} {messages.trending} - ) diff --git a/packages/mobile/src/screens/notifications-screen/Notifications/TrendingUndergroundNotification.tsx b/packages/mobile/src/screens/notifications-screen/Notifications/TrendingUndergroundNotification.tsx index 36cd835af33..c5009860385 100644 --- a/packages/mobile/src/screens/notifications-screen/Notifications/TrendingUndergroundNotification.tsx +++ b/packages/mobile/src/screens/notifications-screen/Notifications/TrendingUndergroundNotification.tsx @@ -1,7 +1,6 @@ import { useCallback } from 'react' import { useNotificationEntity } from '@audius/common/api' -import { Name } from '@audius/common/models' import type { TrackEntity, TrendingUndergroundNotification as TrendingUndergroundNotificationType @@ -16,16 +15,14 @@ import { NotificationHeader, NotificationText, NotificationTile, - NotificationTitle, - NotificationXButton + NotificationShareCardButton, + NotificationTitle } from '../Notification' const messages = { title: "You're Trending", is: 'is', trending: 'on Underground Trending right now!', - xShareText: (entityTitle: string) => - `My track ${entityTitle} made it to the top of underground trending on @audius! Check it out! $AUDIO` } type TrendingUndergroundNotificationProps = { @@ -48,7 +45,6 @@ export const TrendingUndergroundNotification = ( if (!entity) return null - const shareText = messages.xShareText(entity.title) return ( @@ -58,14 +54,9 @@ export const TrendingUndergroundNotification = ( {messages.is} #{rank} {messages.trending} - ) diff --git a/packages/web/src/components/share-modal/ShareModal.tsx b/packages/web/src/components/share-modal/ShareModal.tsx index 7b23980360e..a93867d5a57 100644 --- a/packages/web/src/components/share-modal/ShareModal.tsx +++ b/packages/web/src/components/share-modal/ShareModal.tsx @@ -75,7 +75,10 @@ export const ShareModal = NiceModal.create(() => { defaultUserList: 'chats' }) dispatch( - make(Name.CHAT_ENTRY_POINT, { source: 'share', kind: content.type }) + make(Name.CHAT_ENTRY_POINT, { + source: 'share', + kind: content.type === 'milestone' ? 'track' : content.type + }) ) }, [openCreateChatModal, dispatch, onClose, content]) @@ -91,6 +94,7 @@ export const ShareModal = NiceModal.create(() => { if (!source || !content) return switch (content.type) { case 'track': + case 'milestone': dispatch(shareTrack(content.track.track_id, source)) break case 'contest': diff --git a/packages/web/src/components/share-modal/messages.ts b/packages/web/src/components/share-modal/messages.ts index 4918579c123..969c3c45080 100644 --- a/packages/web/src/components/share-modal/messages.ts +++ b/packages/web/src/components/share-modal/messages.ts @@ -6,7 +6,8 @@ const shareTypeMap: Record = { album: 'Album', playlist: 'Playlist', contest: 'Contest', - weeklyRotation: 'Weekly Rotation' + weeklyRotation: 'Weekly Rotation', + milestone: 'Milestone' } export const messages = { diff --git a/packages/web/src/components/share-modal/utils.ts b/packages/web/src/components/share-modal/utils.ts index 635c263199a..7f0bbc3dc2b 100644 --- a/packages/web/src/components/share-modal/utils.ts +++ b/packages/web/src/components/share-modal/utils.ts @@ -33,7 +33,9 @@ export const getXShareText = async ( let link = '' let analyticsEvent: ShareToTwitterEvent switch (content.type) { - case 'track': { + // Web has no stat card yet, so milestones share as their track + case 'track': + case 'milestone': { const { track: { title, permalink, track_id }, artist