-
Notifications
You must be signed in to change notification settings - Fork 2
feat: 게시판 1차 기능구현 #76
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
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
382f425
fix: 토큰 만료로 reissue 실패시 로그아웃 안되는 문제 해결
nirii00 19fa072
fix: reissue 에러 시 에러 처리 안되는 문제 해결
nirii00 d3840a3
fix: mailbox에서 isClosed 옵션 반대로 보여주는 문제 해결
nirii00 8ee6b97
fix: 401 에러가 아닌 경우 바로 로그아웃 되는 문제 해결
nirii00 f0a803f
FIx: format date 로직 수정
nirii00 34a80e7
fix: mailBox 배포 api에 따른 수정 작업
nirii00 bef18ee
refactor: PR 리뷰를 반영한 리팩토링 (#70)
tifsy e21092d
fix: 게시판 편지 공유 모달 오류 해결 (#73)
tifsy 0bd30f4
fix: 토큰 만료로 reissue 실패시 로그아웃 안되는 문제 해결
nirii00 340f350
fix: reissue 에러 시 에러 처리 안되는 문제 해결
nirii00 1273e13
fix: mailbox에서 isClosed 옵션 반대로 보여주는 문제 해결
nirii00 0dc5aa8
fix: mailBox 배포 api에 따른 수정 작업
nirii00 7a421df
feat: myPage 데이터 바인딩 수정, api 추가
nirii00 429deae
fix: 로그인 reissue 로직 수정
nirii00 6a95bdb
fix: 무한 요청 에러 수정
nirii00 f50d008
feat: 게시판 데이터 바인딩
nirii00 a8a045c
Merge branch 'develop' into 59-feat-like
nirii00 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
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 |
|---|---|---|
|
|
@@ -9,27 +9,27 @@ const client = axios.create({ | |
| headers: { 'Content-Type': 'application/json' }, | ||
| }); | ||
|
|
||
| type FailedRequest = { | ||
| resolve: (token: string) => void; | ||
| reject: (error: unknown) => void; | ||
| }; | ||
| // type FailedRequest = { | ||
| // resolve: (token: string) => void; | ||
| // reject: (error: unknown) => void; | ||
| // }; | ||
|
|
||
| let isRefreshing = false; | ||
| let failedQueue: FailedRequest[] = []; | ||
|
|
||
| const processQueue = (error: unknown, token: string | null = null) => { | ||
| failedQueue.forEach((prom) => { | ||
| if (error) { | ||
| prom.reject(error); | ||
| } else { | ||
| if (token) { | ||
| prom.resolve(token); | ||
| } | ||
| } | ||
| }); | ||
|
|
||
| failedQueue = []; | ||
| }; | ||
| // let failedQueue: FailedRequest[] = []; | ||
|
|
||
| // const processQueue = (error: unknown, token: string | null = null) => { | ||
| // failedQueue.forEach((prom) => { | ||
| // if (error) { | ||
| // prom.reject(error); | ||
| // } else { | ||
| // if (token) { | ||
| // prom.resolve(token); | ||
| // } | ||
| // } | ||
| // }); | ||
|
|
||
| // failedQueue = []; | ||
| // }; | ||
|
|
||
| const callReissue = async () => { | ||
| try { | ||
|
|
@@ -41,6 +41,8 @@ const callReissue = async () => { | |
| } | ||
| }; | ||
|
|
||
| let retry = false; | ||
|
|
||
| client.interceptors.request.use( | ||
| (config) => { | ||
| console.log('response again', config); | ||
|
|
@@ -68,43 +70,42 @@ client.interceptors.response.use( | |
| return Promise.reject(error); | ||
| } | ||
|
|
||
| if ( | ||
| (error.response?.status === 401 || error.response?.status === 403) && | ||
| !originalRequest._retry | ||
| ) { | ||
| originalRequest._retry = true; | ||
|
|
||
| if ((error.response?.status === 401 || error.response?.status === 403) && !retry) { | ||
| retry = true; | ||
| if (isRefreshing) { | ||
| try { | ||
| return new Promise((resolve, reject) => { | ||
| failedQueue.push({ | ||
| resolve: (token: string) => { | ||
| originalRequest.headers.Authorization = `Bearer ${token}`; | ||
| resolve(client(originalRequest)); | ||
| }, | ||
| reject: (err: unknown) => reject(err), | ||
| }); | ||
| }); | ||
| } catch (e) { | ||
| return Promise.reject(e); | ||
| } | ||
| if (isLoggedIn) logout(); | ||
| // try { | ||
| // return new Promise((resolve, reject) => { | ||
| // failedQueue.push({ | ||
| // resolve: (token: string) => { | ||
| // originalRequest.headers.Authorization = `Bearer ${token}`; | ||
| // resolve(client(originalRequest)); | ||
| // }, | ||
| // reject: (err: unknown) => reject(err), | ||
| // }); | ||
| // }); | ||
| // } catch (e) { | ||
| // return Promise.reject(e); | ||
| // } | ||
|
Comment on lines
+77
to
+89
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 요것두! |
||
| } else { | ||
| isRefreshing = true; | ||
| try { | ||
| const newToken = await callReissue(); | ||
| setAccessToken(newToken); | ||
| processQueue(null, newToken); | ||
| // processQueue(null, newToken); | ||
| isRefreshing = false; | ||
| originalRequest.headers.Authorization = `Bearer ${newToken}`; | ||
| return client(originalRequest); | ||
| } catch (e) { | ||
| processQueue(e, null); | ||
| // processQueue(e, null); | ||
| isRefreshing = false; | ||
| if (isLoggedIn) logout(); | ||
| return Promise.reject(e); | ||
| } | ||
| } | ||
| } | ||
| if (isLoggedIn) logout(); | ||
| console.error('Failed to refresh token', error); | ||
| return Promise.reject(error); | ||
| }, | ||
| ); | ||
|
|
||
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,26 +1,27 @@ | ||
| import { Link } from 'react-router'; | ||
| import { forwardRef } from 'react'; | ||
| import { useNavigate } from 'react-router'; | ||
|
|
||
| import LetterWrapper from '@/components/LetterWrapper'; | ||
|
|
||
| interface LetterPreviewProps { | ||
| id: string; | ||
| id: number; | ||
| to: string; | ||
| from: string; | ||
| content: string; | ||
| } | ||
|
|
||
| const LetterPreview = ({ id, to, from, content }: LetterPreviewProps) => { | ||
| const LetterPreview = forwardRef<HTMLDivElement, LetterPreviewProps>((props, ref) => { | ||
| const { id, to, from, content }: LetterPreviewProps = props; | ||
| const navigate = useNavigate(); | ||
| return ( | ||
| <Link to={id}> | ||
| <LetterWrapper className="px-3 py-2"> | ||
| <div className="caption-r flex flex-col gap-2"> | ||
| <p>From.{from}</p> | ||
| <p className="line-clamp-2 font-light">{content}</p> | ||
| <p className="place-self-end">To.{to}</p> | ||
| </div> | ||
| </LetterWrapper> | ||
| </Link> | ||
| <LetterWrapper className="px-3 py-2" ref={ref} onClick={() => navigate(`/board/letter/${id}`)}> | ||
| <div className="caption-r flex flex-col gap-2"> | ||
| <p>From.{from}</p> | ||
| <p className="line-clamp-2 font-light">{content}</p> | ||
| <p className="place-self-end">To.{to}</p> | ||
| </div> | ||
| </LetterWrapper> | ||
| ); | ||
| }; | ||
| }); | ||
|
|
||
| export default LetterPreview; |
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
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.
이 주석들은 임시처리인가요 아니면 삭제될 코드들인가요??
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.
임시 처리입니다! 혹시 요청이 여러번 생기는 경우에 어떻게 될지 몰라서 일단은 이 로직을 참고하려고 놔뒀어요!