@@ -3,6 +3,7 @@ import React, { useCallback, useRef } from 'react'
3
3
import {
4
4
accountSelectors ,
5
5
collectionsSocialActions ,
6
+ createChatModalActions ,
6
7
FeatureFlags ,
7
8
shareModalUISelectors ,
8
9
shareSoundToTiktokModalActions ,
@@ -16,12 +17,15 @@ import { useDispatch, useSelector } from 'react-redux'
16
17
17
18
import IconInstagram from 'app/assets/images/iconInstagram.svg'
18
19
import IconLink from 'app/assets/images/iconLink.svg'
20
+ import IconMessage from 'app/assets/images/iconMessage.svg'
19
21
import IconShare from 'app/assets/images/iconShare.svg'
20
22
import IconSnapchat from 'app/assets/images/iconSnapchat.svg'
21
23
import TikTokIcon from 'app/assets/images/iconTikTokInverted.svg'
22
24
import IconTwitterBird from 'app/assets/images/iconTwitterBird.svg'
25
+ import { useNavigation } from 'app/hooks/useNavigation'
23
26
import { useFeatureFlag } from 'app/hooks/useRemoteConfig'
24
27
import { useToast } from 'app/hooks/useToast'
28
+ import type { AppTabScreenParamList } from 'app/screens/app-screen'
25
29
import { makeStyles } from 'app/styles'
26
30
import { useThemeColors } from 'app/utils/theme'
27
31
@@ -39,6 +43,7 @@ const { shareUser } = usersSocialActions
39
43
const { shareTrack } = tracksSocialActions
40
44
const { shareCollection } = collectionsSocialActions
41
45
const { getAccountUser } = accountSelectors
46
+ const { setState : setCreateChatModalState } = createChatModalActions
42
47
43
48
export const shareToastTimeout = 1500
44
49
@@ -81,6 +86,7 @@ const useStyles = makeStyles(({ spacing }) => ({
81
86
export const ShareDrawer = ( ) => {
82
87
const styles = useStyles ( )
83
88
const viewShotRef = useRef ( ) as React . RefObject < ViewShot >
89
+ const navigation = useNavigation < AppTabScreenParamList > ( )
84
90
85
91
const { isEnabled : isShareSoundToTikTokEnabled } = useFeatureFlag (
86
92
FeatureFlags . SHARE_SOUND_TO_TIKTOK
@@ -100,6 +106,17 @@ export const ShareDrawer = () => {
100
106
101
107
const isPremiumTrack = content ?. type === 'track' && content . track . is_premium
102
108
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
+
103
120
const handleShareToTwitter = useCallback ( async ( ) => {
104
121
if ( ! content ) return
105
122
const twitterShareUrl = await getTwitterShareUrl ( content )
@@ -166,6 +183,12 @@ export const ShareDrawer = () => {
166
183
)
167
184
168
185
const getRows = useCallback ( ( ) => {
186
+ const shareToChatAction = {
187
+ icon : < IconMessage fill = { secondary } height = { 26 } width = { 26 } /> ,
188
+ text : messages . directMessage ,
189
+ callback : handleShareToDirectMessage
190
+ }
191
+
169
192
const shareToTwitterAction = {
170
193
icon : < IconTwitterBird fill = { secondary } height = { 20 } width = { 26 } /> ,
171
194
text : messages . twitter ,
@@ -185,13 +208,13 @@ export const ShareDrawer = () => {
185
208
}
186
209
187
210
const copyLinkAction = {
188
- text : messages . copyLink ( shareType ) ,
211
+ text : messages . copyLink ,
189
212
icon : < IconLink height = { 26 } width = { 26 } fill = { secondary } /> ,
190
213
callback : handleCopyLink
191
214
}
192
215
193
216
const shareSheetAction = {
194
- text : messages . shareSheet ( shareType ) ,
217
+ text : messages . shareSheet ,
195
218
icon : < IconShare height = { 26 } width = { 26 } fill = { secondary } /> ,
196
219
callback : handleOpenShareSheet
197
220
}
@@ -213,16 +236,16 @@ export const ShareDrawer = () => {
213
236
icon : React . ReactElement
214
237
style ?: Record < string , string >
215
238
callback : ( ( ) => void ) | ( ( ) => Promise < void > )
216
- } [ ] = [ shareToTwitterAction ]
239
+ } [ ] = [ shareToChatAction , shareToTwitterAction ]
217
240
218
241
if ( shouldIncludeTikTokSoundAction ) {
219
242
result . push ( shareSoundToTiktokAction )
220
243
}
221
244
222
245
if ( isShareableTrack ) {
223
246
result . push ( shareToInstagramStoriesAction )
224
- result . push ( shareToSnapchatAction )
225
247
result . push ( shareVideoToTiktokAction )
248
+ result . push ( shareToSnapchatAction )
226
249
}
227
250
228
251
result . push ( copyLinkAction , shareSheetAction )
@@ -231,15 +254,15 @@ export const ShareDrawer = () => {
231
254
} , [
232
255
handleShareToTwitter ,
233
256
handleShareSoundToTikTok ,
234
- shareType ,
235
257
secondary ,
236
258
handleCopyLink ,
237
259
handleOpenShareSheet ,
238
260
handleShareToSnapchat ,
239
261
handleShareToInstagramStory ,
240
262
shouldIncludeTikTokSoundAction ,
241
263
isShareableTrack ,
242
- handleShareVideoToTiktok
264
+ handleShareVideoToTiktok ,
265
+ handleShareToDirectMessage
243
266
] )
244
267
245
268
return (
0 commit comments