-
Notifications
You must be signed in to change notification settings - Fork 2
[DEPLOY] 회원 탈퇴 API 연결 등 적용 #269
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
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
4c1064c
fix: 리포트 삭제 시 optimistic update 적용으로 지연 개선
sejeong223 a385af5
feat: 사이드바에 피드백 아이콘 추가
sejeong223 1101034
feat: 회원 탈퇴 api 요청 함수 추가
sejeong223 c3801bb
fix: 파일 이름 오타 수정
sejeong223 b02cff6
feat: 회원 탈퇴 api 연동
sejeong223 62b9c95
GA 작업
MunJinYeong 26003d0
CHORE: Update pnpm-lock.yaml for react-ga4
MunJinYeong 9e31233
feat: 회원 탈퇴 처리 중 모달 닫기 방지 로직 추가
sejeong223 48536e2
Merge pull request #264 from channeling-ai/fix/report-delete-delay
sejeong223 652f4f4
Merge pull request #259 from channeling-ai/dev/sidebar-feeback-button
sejeong223 3afabf9
리뷰 코멘트 반영
MunJinYeong 5281c1d
빌드 에러 수정
MunJinYeong 574fef3
Merge pull request #268 from channeling-ai/dev/ga4
drddyn 1a293ea
Merge branch 'develop' into dev/api-withdraw
drddyn d8b9352
chore: App.tsx에서 GoogleAnalytics 삭제
drddyn f94445d
feat: 로그아웃 상태일 시 탈퇴 모달 닫히게 설정
drddyn b134103
Merge pull request #266 from channeling-ai/dev/api-withdraw
drddyn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { useEffect } from 'react' | ||
| import { useLocation } from 'react-router-dom' | ||
| import { initGA, trackPageView } from '../utils/analytics' | ||
|
|
||
| /** | ||
| * Google Analytics 초기화 및 페이지뷰 트래킹을 담당하는 컴포넌트 | ||
| */ | ||
| export const GoogleAnalytics = () => { | ||
| const location = useLocation() | ||
|
|
||
| // GA 초기화 (최초 1회만 실행) | ||
| useEffect(() => { | ||
| initGA() | ||
| }, []) | ||
|
|
||
| // 페이지 이동 시 페이지뷰 트래킹 | ||
| useEffect(() => { | ||
| trackPageView(location.pathname + location.search) | ||
| }, [location]) | ||
|
|
||
| return null | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,49 @@ | ||
| import { useMutation, useQueryClient } from '@tanstack/react-query' | ||
| import type { DeleteMyReport, ResponseDeleteMyReport } from '../../types/report/all' | ||
| import type { BriefReport, DeleteMyReport, ResponseDeleteMyReport } from '../../types/report/all' | ||
| import { deleteMyReport } from '../../api/report' | ||
|
|
||
| type MyReportQueryData = { | ||
| reportList: BriefReport[] | ||
| totalElements: number | ||
| } | ||
|
|
||
| type DeleteReportContext = { | ||
| previousData?: MyReportQueryData | ||
| } | ||
|
|
||
| export const useDeleteMyReport = ({ channelId }: { channelId: number | undefined }) => { | ||
| const queryClient = useQueryClient() | ||
|
|
||
| return useMutation<ResponseDeleteMyReport, Error, DeleteMyReport>({ | ||
| return useMutation<ResponseDeleteMyReport, Error, DeleteMyReport, DeleteReportContext>({ | ||
| mutationFn: deleteMyReport, | ||
| onSuccess: () => { | ||
|
|
||
| onMutate: async ({ reportId }) => { | ||
| if (typeof channelId !== 'number') return {} | ||
| const queryKey = ['my', 'report', channelId] | ||
| await queryClient.cancelQueries({ queryKey }) | ||
| const previousData = queryClient.getQueryData<MyReportQueryData>(queryKey) | ||
| queryClient.setQueryData<MyReportQueryData>(queryKey, (old) => { | ||
| if (!old) return old | ||
| return { | ||
| ...old, | ||
| reportList: old.reportList.filter((report) => report.reportId !== reportId), | ||
| totalElements: old.totalElements - 1, | ||
| } | ||
| }) | ||
| return { previousData } | ||
| }, | ||
| onError: (_error, _variables, context) => { | ||
| if (typeof channelId === 'number' && context?.previousData) { | ||
| queryClient.setQueryData(['my', 'report', channelId], context.previousData) | ||
| } | ||
| alert('리포트 삭제 중 오류가 발생했습니다.') | ||
| }, | ||
|
|
||
| onSettled: () => { | ||
| if (typeof channelId === 'number') { | ||
| queryClient.invalidateQueries({ queryKey: ['my', 'report', channelId] }) | ||
| queryClient.invalidateQueries({ queryKey: ['recommendedVideos'] }) | ||
| } | ||
| }, | ||
| onError: () => { | ||
| alert('리포트 삭제 중 오류가 발생했습니다.') | ||
| }, | ||
| }) | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
리포트 목록에 대한 낙관적 업데이트를 구현하신 점이 좋습니다. 하지만 현재
onMutate와onError에서 사용된setQueryData와getQueryData는 정확한 쿼리 키를 필요로 합니다. 리포트 목록 쿼리는 페이징 및 필터링(type)을 포함하므로,['my', 'report', channelId]와 같은 부분적인 키로는 캐시된 데이터를 정확히 찾아 업데이트하거나 롤백하기 어렵습니다. 이로 인해 낙관적 업데이트가 UI에 반영되지 않을 가능성이 높습니다.모든 관련 페이지 캐시에 대해 업데이트를 적용하려면
setQueriesData를 필터와 함께 사용하는 것을 고려해 보세요. 이 로직이 의도한 대로 동작하는지 다시 한번 확인해 보시는 것을 추천합니다.