-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#81] Feat: 짤 이미지 삭제 api 연결 및 성공/삭제 시 동작 구현 #86
Conversation
useMutation을 이용 /v1/image/ url로 삭제 요청 TODO: 이미지 상세보기 api 연결 후, 실제 imageId 전달해야합니다. TODO: 삭제 API 요청이 성공하면, 모달을 닫고 페이지를 새로고침해야합니다.
toastify 사용 짤 이미지 삭제 성공 시 모달 자동으로 닫히도록 구현 TODO: 짤 이미지 삭제 성공 시 페이지 새로고침 TODO: 이미지 상세 모달 구현 시, 유저 본인이 업로드한 이미지가 아닐 경우 삭제 버튼 비활성화 구현 필요
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
d5bf0a3
to
d527ac1
Compare
삭제시, 새로고침이 필요한건 아닐거예요! 삭제 성공후 querykey invalidate 시켜주면 아마 원하시는대로 동작하지 않을까 합니다. 한 번 알아보고 적용해주세요! |
감사합니다 😀 혹시 삭제 성공 후 쿼리를 무효화하는 걸 말씀하시는게 맞다면, 위 코드가 구현된 후에 추가할 수 있을 것 같은데 어떻게 생각하시나요? |
@HY219 넵 맞습니다! 새로고침으로 표현해주셔서 잘못 이해하고 계신 줄 알고 팁을 드렸습니다ㅎㅎ 어차피 업로드한 짤과 좋아요한 짤은 페이지 진입시에 재요청하니 굳이 invalidate 해줄 필요는 없을 것 같습니다~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이미지 상세 모달 UI가 변경되면서 ImageMenuBar가 제거되고 index에 버튼이 다 모인 구조로 변경되었습니다. 위치만 바뀐 거여서 나중에 코드가 옮겨질 수 있을 것 같네요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 감사합니다! 그럼 이미지 상세 모달 UI가 머지된 후에 코드 수정 후 머지하는게 좋겠네요:)
제가 표현을 잘 못 쓴 것 같네요! 🤣 모달이 닫히는 경우에 페이지에 진입하는 걸 알 수 있나요? 같은 url 창에서 모달을 열었다 닫았을 때 진입해 있던 페이지에 영향을 주거나, 재진입했다고 인식하지 못할 것 같은데 어떻게 생각하시나요? |
TODO: 모달 클릭 시 URL이 변경되도록 구현 후, 이미지 삭제 성공 시 이전 페이지로 이동하는 navigate 추가
#81/feature/delete-my-zzal-api
const [isLiked, setIsLiked] = useState(false); | ||
|
||
const handleClickLike = () => { | ||
setIsLiked((prevLiked) => !prevLiked); | ||
}; | ||
|
||
const { deleteMyZzal } = useDeleteMyZzal(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api 커스텀 훅은 상단에 위치시키면 더 잘 보일 거 같아요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
넵 👍 놓쳤네요 감사합니다!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
해당 api 훅은
- 관리자 페이지에서 신고 사진을 삭제하는 기능인가요
- 이미지 상세 모달에서 본인 사진을 삭제하는 기능인가요?
만약 2번이라면 디렉토리 구조 수정하셔야 할 것 같습니다!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오 그러네요...ㄷㄷㄷ머지될뻔
const { mutate, ...rest } = useMutation({ | ||
mutationFn: deleteMyZzal, | ||
onSuccess: () => { | ||
toast.success("사진이 삭제되었습니다."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[내 사진 삭제] 후 masonry layout의 사진들은 업데이트가 되나요?
invalidateQueries
나 setQueryData
로 캐시 업데이트를 해야 할 것 같은데 어떻게 생각하시나요?
아래 시나리오를 적어봤는데 혹시 아래와 같은 상황이 발생한다면 invalidateQueries로 한번 다시 데이터를 받아오는 게 좋을 것 같습니다
[시나리오]
본인이 올린 사진 A를 홈의 masonry layout에서 클릭해서 이미지 상세 모달로 이동 -> 모달에서 사진 삭제 성공 -> 모달 닫히고, 다시 홈의 masonry layout으로 이동 -> 이때 masonry layout의 사진들은 이미지 삭제하기 전의 캐시라 방금 삭제한 이미지가 보인다
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO 사항이군요~ 네버마인드 :)
TODO 주석 달아주세요!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onSuccess와 onError에 관한 코드 ImageMenuBar 파일로 위치 변경해줬습니다! useDeleteMyZzal에서 onSuccess를 중복으로 작성하지 않아도 될 것 같았습니다:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 입니다~ 💯 '
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
저도 LGTM 입니닷!
📝 작업 내용
/v1/image/${imageId}
-DELETE
toastify
이용Context API
이용onSuccess 콜백
이용📷 스크린샷 (선택)
💬 리뷰 요구사항(선택)
+추가로 궁금한 사항이 있습니다!
int
값으로 전달 받는데, url일 경우string
으로 지정해줘야하나요?현재 코드에서는 number로 받고 있는데, string으로 변경해줘야하는지 궁금합니다!
다음과 같이 에러가 뜨는데, 캐시 무효화 문제인지, 배포 ID 문제인지 해결이 어려워 도움 요청합니다.
![image](https://private-user-images.githubusercontent.com/82134668/309538071-9016151e-8e41-43c2-84e0-4b1327c3a8c5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyMjY3MzUsIm5iZiI6MTczOTIyNjQzNSwicGF0aCI6Ii84MjEzNDY2OC8zMDk1MzgwNzEtOTAxNjE1MWUtOGU0MS00M2MyLTg0ZTAtNGIxMzI3YzNhOGM1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEwVDIyMjcxNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWZkYzFmMGI2ZDMzNTFlYjMxMjlmM2M5YWYyMzJmMmJlOWJjNWQwZGYxMThkMDA2NWIyNDU1ZjI2ZDExYmFiYTMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.0OXNR1y0YD_qwAK9aSC5O9Iy3WivZCWl9dm-EbJPkTA)
📍 기타 (선택)
새로고침 필요쿼리 무효화 필요TODO: [2024-03-03] 이미지 상세 모달 구현 코드에 따라 변경될 수 있습니다. (이미지 삭제 성공 시, 모달이 닫히는 동작을 구현하기 위해 코드 구현)
-> 짤 클릭 시 모달 열고 닫는 코드close #81