@@ -3,13 +3,13 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom'
33
44import styled from 'styled-components'
55
6+ import { ChatProvider } from '@/app/providers/ChatProvider'
67import { usePlaylist } from '@/app/providers/PlayerProvider'
78import { NoLike } from '@/assets/icons'
89import { MemberCharacter } from '@/assets/images'
910import { usePlaylistDetail } from '@/entities/playlist'
1011import { useMyCdActions , useMyCdList , useMyLikedCdList } from '@/entities/playlist/model/useMyCd'
1112import { useAuthStore } from '@/features/auth/store/authStore'
12- import { useChatSocket } from '@/features/chat/model/sendMessage'
1313import { HeaderTab , PlaylistCarousel } from '@/pages/mycd/ui'
1414import type { MyCdTab } from '@/pages/mycd/ui/HeaderTab'
1515import { useDevice } from '@/shared/lib/useDevice'
@@ -136,11 +136,6 @@ const MyCdPage = () => {
136136 }
137137 } , [ playlistDetail , userInfo , setPlaylist , currentPlaylist ] )
138138
139- const isActive = currentPlaylist ?. playlistId === playlistDetail ?. playlistId
140- const { participantCount : listenersNum } = useChatSocket (
141- isActive && centerItem . playlistId ? String ( centerItem . playlistId ) : ''
142- )
143-
144139 const handleProgressClick = useCallback (
145140 ( trackIndex : number , seconds : number ) => {
146141 if ( ! currentPlaylist ) return
@@ -190,73 +185,75 @@ const MyCdPage = () => {
190185 }
191186
192187 return (
193- < div >
194- { currentPlaylist && (
195- < >
196- < HeaderTab selectedTab = { selectedTab } onSelect = { handleTabSelect } />
197- < Container >
198- < LiveInfo isOnAir = { listenersNum > 0 } listenerCount = { listenersNum } />
199- { selectedTab === 'MY' && (
200- < Button
201- size = "S"
202- state = "primary"
203- onClick = { ( ) =>
204- navigate ( `/mypage/customize` , {
205- state : { cdId : currentPlaylist ?. playlistId } ,
206- } )
207- }
208- >
209- 편집
210- </ Button >
211- ) }
212- </ Container >
213- < CenterWrapper >
214- < PlaylistCarousel
215- data = { playlistData ?? [ ] }
216- onCenterChange = { handleCenterChange }
217- currentPlaylistId = { currentPlaylist ?. playlistId }
218- isPlaying = { isPlaying }
219- />
220- < ActionBar
221- playlistId = { centerItem . playlistId ?? 0 }
222- creatorId = { currentPlaylist . creatorId }
223- stickers = { playlistDetail ?. cdResponse ?. cdItems || [ ] }
224- type = "MY"
225- selectedTab = { selectedTab }
226- />
227- < Title $isMobile = { isMobile } > { centerItem . playlistName } </ Title >
228- { selectedTab === 'LIKE' && playlistDetail ?. creatorNickname && (
229- < Creator > { playlistDetail . creatorNickname } </ Creator >
230- ) }
231-
232- < BottomWrapper >
233- < ProgressBar
234- trackLengths = { currentPlaylist . songs . map ( ( t ) => t . youtubeLength ) || [ ] }
235- currentIndex = { currentTrackIndex }
236- onClick = { handleProgressClick }
237- />
238-
239- < ControlBar
240- isPlaying = { isPlaying }
241- onTogglePlay = { ( ) => {
242- if ( isMobile && ! isPlaying ) {
243- unmuteOnce ( )
188+ < ChatProvider roomId = { currentPlaylist ? String ( currentPlaylist . playlistId ) : '' } >
189+ < div >
190+ { currentPlaylist && (
191+ < >
192+ < HeaderTab selectedTab = { selectedTab } onSelect = { handleTabSelect } />
193+ < Container >
194+ < LiveInfo />
195+ { selectedTab === 'MY' && (
196+ < Button
197+ size = "S"
198+ state = "primary"
199+ onClick = { ( ) =>
200+ navigate ( `/mypage/customize` , {
201+ state : { cdId : currentPlaylist ?. playlistId } ,
202+ } )
244203 }
245-
246- if ( isPlaying ) {
247- pause ( )
248- } else {
249- play ( )
250- }
251- } }
252- onNext = { nextTrack }
253- onPrev = { prevTrack }
204+ >
205+ 편집
206+ </ Button >
207+ ) }
208+ </ Container >
209+ < CenterWrapper >
210+ < PlaylistCarousel
211+ data = { playlistData ?? [ ] }
212+ onCenterChange = { handleCenterChange }
213+ currentPlaylistId = { currentPlaylist ?. playlistId }
214+ isPlaying = { isPlaying }
215+ />
216+ < ActionBar
217+ playlistId = { centerItem . playlistId ?? 0 }
218+ creatorId = { currentPlaylist . creatorId }
219+ stickers = { playlistDetail ?. cdResponse ?. cdItems || [ ] }
220+ type = "MY"
221+ selectedTab = { selectedTab }
254222 />
255- </ BottomWrapper >
256- </ CenterWrapper >
257- </ >
258- ) }
259- </ div >
223+ < Title $isMobile = { isMobile } > { centerItem . playlistName } </ Title >
224+ { selectedTab === 'LIKE' && playlistDetail ?. creatorNickname && (
225+ < Creator > { playlistDetail . creatorNickname } </ Creator >
226+ ) }
227+
228+ < BottomWrapper >
229+ < ProgressBar
230+ trackLengths = { currentPlaylist . songs . map ( ( t ) => t . youtubeLength ) || [ ] }
231+ currentIndex = { currentTrackIndex }
232+ onClick = { handleProgressClick }
233+ />
234+
235+ < ControlBar
236+ isPlaying = { isPlaying }
237+ onTogglePlay = { ( ) => {
238+ if ( isMobile && ! isPlaying ) {
239+ unmuteOnce ( )
240+ }
241+
242+ if ( isPlaying ) {
243+ pause ( )
244+ } else {
245+ play ( )
246+ }
247+ } }
248+ onNext = { nextTrack }
249+ onPrev = { prevTrack }
250+ />
251+ </ BottomWrapper >
252+ </ CenterWrapper >
253+ </ >
254+ ) }
255+ </ div >
256+ </ ChatProvider >
260257 )
261258}
262259
0 commit comments