Skip to content

Commit

Permalink
Merge pull request #26 from GihoKo/llt-23
Browse files Browse the repository at this point in the history
[Llt-23] 채널에서 다른 채널에 옮길때 플레이리스트가 안불러와지는 버그 수정
  • Loading branch information
GihoKo authored Aug 1, 2024
2 parents 28ae145 + ce84997 commit 78d5f71
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/apis/services/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const getAllchannelLists = async () => {
export const getChannelById = async (channelId: string | undefined) => {
try {
const response = await axiosInstanceWithToken.get(`/channels/${channelId}`);
console.log('response:', response.data);
return response.data;
} catch (error) {
console.error(error);
Expand Down
1 change: 0 additions & 1 deletion src/apis/services/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const updateUser = async (userId: string | undefined, user: FormData) =>
export const getMyChannelList = async (userId: string | undefined) => {
try {
const response = await axiosInstanceWithToken.get(`/users/myChannels/${userId}`);
console.log(response.data);
return response.data;
} catch (error) {
console.error(error);
Expand Down
18 changes: 10 additions & 8 deletions src/pages/Main/Channel/Channel.hook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function useChannel() {
const { setChannelId } = useChannelIdStore();
const [musicList, setMusicList] = useState<Music[]>([]);
const { music: currentMusic, setMusic, resetMusic } = useMusicStore();
const { data, isLoading, isError } = useGetMusicsByChannelId(channelId);
const { data: musicListData, isLoading, isError, refetch } = useGetMusicsByChannelId(channelId);
const [personalTap, setPersonalTap] = useState([
{ name: 'Player', value: 0, isFocused: false },
{ name: 'List', value: 1, isFocused: true },
Expand Down Expand Up @@ -49,15 +49,17 @@ export default function useChannel() {
};

useEffect(() => {
if (data) {
setMusicList(data);
setChannelId(channelId);
if (channelId) {
refetch();
}
}, [refetch, channelId]);

return () => {
resetMusic();
};
}, [data, channelId]);
useEffect(() => {
if (musicListData) {
setMusicList(musicListData);
setChannelId(channelId);
}
}, [musicListData]);

return {
musicList,
Expand Down

0 comments on commit 78d5f71

Please sign in to comment.