Skip to content

Commit 977ecd9

Browse files
committed
[PAY-1688] Mobile: Share track, collection to DMs (#3840)
1 parent 85a5c30 commit 977ecd9

File tree

3 files changed

+44
-14
lines changed

3 files changed

+44
-14
lines changed

apps/audius-client/packages/mobile/src/components/share-drawer/ShareDrawer.tsx

+29-6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { useCallback, useRef } from 'react'
33
import {
44
accountSelectors,
55
collectionsSocialActions,
6+
createChatModalActions,
67
FeatureFlags,
78
shareModalUISelectors,
89
shareSoundToTiktokModalActions,
@@ -16,12 +17,15 @@ import { useDispatch, useSelector } from 'react-redux'
1617

1718
import IconInstagram from 'app/assets/images/iconInstagram.svg'
1819
import IconLink from 'app/assets/images/iconLink.svg'
20+
import IconMessage from 'app/assets/images/iconMessage.svg'
1921
import IconShare from 'app/assets/images/iconShare.svg'
2022
import IconSnapchat from 'app/assets/images/iconSnapchat.svg'
2123
import TikTokIcon from 'app/assets/images/iconTikTokInverted.svg'
2224
import IconTwitterBird from 'app/assets/images/iconTwitterBird.svg'
25+
import { useNavigation } from 'app/hooks/useNavigation'
2326
import { useFeatureFlag } from 'app/hooks/useRemoteConfig'
2427
import { useToast } from 'app/hooks/useToast'
28+
import type { AppTabScreenParamList } from 'app/screens/app-screen'
2529
import { makeStyles } from 'app/styles'
2630
import { useThemeColors } from 'app/utils/theme'
2731

@@ -39,6 +43,7 @@ const { shareUser } = usersSocialActions
3943
const { shareTrack } = tracksSocialActions
4044
const { shareCollection } = collectionsSocialActions
4145
const { getAccountUser } = accountSelectors
46+
const { setState: setCreateChatModalState } = createChatModalActions
4247

4348
export const shareToastTimeout = 1500
4449

@@ -81,6 +86,7 @@ const useStyles = makeStyles(({ spacing }) => ({
8186
export const ShareDrawer = () => {
8287
const styles = useStyles()
8388
const viewShotRef = useRef() as React.RefObject<ViewShot>
89+
const navigation = useNavigation<AppTabScreenParamList>()
8490

8591
const { isEnabled: isShareSoundToTikTokEnabled } = useFeatureFlag(
8692
FeatureFlags.SHARE_SOUND_TO_TIKTOK
@@ -100,6 +106,17 @@ export const ShareDrawer = () => {
100106

101107
const isPremiumTrack = content?.type === 'track' && content.track.is_premium
102108

109+
const handleShareToDirectMessage = useCallback(async () => {
110+
if (!content) return
111+
navigation.navigate('ChatUserList')
112+
dispatch(
113+
setCreateChatModalState({
114+
// Just care about the link
115+
presetMessage: getContentUrl(content)
116+
})
117+
)
118+
}, [content, dispatch, navigation])
119+
103120
const handleShareToTwitter = useCallback(async () => {
104121
if (!content) return
105122
const twitterShareUrl = await getTwitterShareUrl(content)
@@ -166,6 +183,12 @@ export const ShareDrawer = () => {
166183
)
167184

168185
const getRows = useCallback(() => {
186+
const shareToChatAction = {
187+
icon: <IconMessage fill={secondary} height={26} width={26} />,
188+
text: messages.directMessage,
189+
callback: handleShareToDirectMessage
190+
}
191+
169192
const shareToTwitterAction = {
170193
icon: <IconTwitterBird fill={secondary} height={20} width={26} />,
171194
text: messages.twitter,
@@ -185,13 +208,13 @@ export const ShareDrawer = () => {
185208
}
186209

187210
const copyLinkAction = {
188-
text: messages.copyLink(shareType),
211+
text: messages.copyLink,
189212
icon: <IconLink height={26} width={26} fill={secondary} />,
190213
callback: handleCopyLink
191214
}
192215

193216
const shareSheetAction = {
194-
text: messages.shareSheet(shareType),
217+
text: messages.shareSheet,
195218
icon: <IconShare height={26} width={26} fill={secondary} />,
196219
callback: handleOpenShareSheet
197220
}
@@ -213,16 +236,16 @@ export const ShareDrawer = () => {
213236
icon: React.ReactElement
214237
style?: Record<string, string>
215238
callback: (() => void) | (() => Promise<void>)
216-
}[] = [shareToTwitterAction]
239+
}[] = [shareToChatAction, shareToTwitterAction]
217240

218241
if (shouldIncludeTikTokSoundAction) {
219242
result.push(shareSoundToTiktokAction)
220243
}
221244

222245
if (isShareableTrack) {
223246
result.push(shareToInstagramStoriesAction)
224-
result.push(shareToSnapchatAction)
225247
result.push(shareVideoToTiktokAction)
248+
result.push(shareToSnapchatAction)
226249
}
227250

228251
result.push(copyLinkAction, shareSheetAction)
@@ -231,15 +254,15 @@ export const ShareDrawer = () => {
231254
}, [
232255
handleShareToTwitter,
233256
handleShareSoundToTikTok,
234-
shareType,
235257
secondary,
236258
handleCopyLink,
237259
handleOpenShareSheet,
238260
handleShareToSnapchat,
239261
handleShareToInstagramStory,
240262
shouldIncludeTikTokSoundAction,
241263
isShareableTrack,
242-
handleShareVideoToTiktok
264+
handleShareVideoToTiktok,
265+
handleShareToDirectMessage
243266
])
244267

245268
return (

apps/audius-client/packages/mobile/src/components/share-drawer/messages.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ export const messages = {
1212
modalTitle: (asset: ShareType) => `Share ${shareTypeMap[asset]}`,
1313
hiddenPlaylistShareHelperText:
1414
'Spread the word! Share your playlist with friends and fans! Hidden playlists will be visible to anyone on the internet with the link.',
15-
twitter: 'Share to Twitter',
16-
instagramStory: 'Share to Instagram Story',
17-
snapchat: 'Share to Snapchat',
18-
tikTokVideo: 'Share to TikTok',
15+
directMessage: 'Direct Message',
16+
twitter: 'Twitter',
17+
instagramStory: ' Instagram Story',
18+
snapchat: 'Snapchat',
19+
tikTokVideo: 'TikTok',
1920
tikTokSound: 'Share Sound to TikTok',
20-
copyLink: (asset: ShareType) => `Copy Link to ${shareTypeMap[asset]}`,
21+
copyLink: 'Copy Link',
2122
shareToStoryError: 'Sorry, something went wrong.',
22-
shareSheet: (asset: ShareType) => `Share ${asset} via...`,
23+
shareSheet: 'More...',
2324
toast: (asset: ShareType) => `Copied Link to ${shareTypeMap[asset]}`,
2425
trackShareText: (title: string, handle: string) =>
2526
`Check out ${title} by ${handle} on @AudiusProject #Audius`,

apps/audius-client/packages/mobile/src/screens/chat-screen/ChatTextInput.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import { useCallback, useState } from 'react'
22

3-
import { chatActions, playerSelectors } from '@audius/common'
3+
import {
4+
chatActions,
5+
createChatModalSelectors,
6+
playerSelectors
7+
} from '@audius/common'
48
import { Platform, Pressable } from 'react-native'
59
import { useDispatch, useSelector } from 'react-redux'
610

@@ -13,6 +17,7 @@ import { useThemeColors } from 'app/utils/theme'
1317

1418
const { sendMessage } = chatActions
1519
const { getHasTrack } = playerSelectors
20+
const { getPresetMessage } = createChatModalSelectors
1621

1722
const messages = {
1823
startNewMessage: ' Start a New Message'
@@ -60,7 +65,8 @@ export const ChatTextInput = ({
6065
const dispatch = useDispatch()
6166
const { primary, primaryDark2 } = useThemeColors()
6267

63-
const [inputMessage, setInputMessage] = useState('')
68+
const presetMessage = useSelector(getPresetMessage)
69+
const [inputMessage, setInputMessage] = useState(presetMessage ?? '')
6470
const hasLength = inputMessage.length > 0
6571
const hasCurrentlyPlayingTrack = useSelector(getHasTrack)
6672

0 commit comments

Comments
 (0)