From fbcd7e3496c1836c448da8fe218511767fd2d1d4 Mon Sep 17 00:00:00 2001 From: nimod7890 Date: Tue, 20 Aug 2024 14:44:24 +0900 Subject: [PATCH 1/7] fix: typo --- packages/user/src/hooks/socket/useChatSocket.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/user/src/hooks/socket/useChatSocket.ts b/packages/user/src/hooks/socket/useChatSocket.ts index a76ee866..76b51f7e 100644 --- a/packages/user/src/hooks/socket/useChatSocket.ts +++ b/packages/user/src/hooks/socket/useChatSocket.ts @@ -22,16 +22,17 @@ export default function useChatSocket() { [], ); - const handleIncomintBlock: SocketSubscribeCallbackType = useCallback( + const handleIncomingBlock: SocketSubscribeCallbackType = useCallback( (data: unknown) => { const { blockId } = data as { blockId: string }; - setChatMessages(prevMessages => { + setChatMessages((prevMessages) => { const tmpMessages = prevMessages.slice(); tmpMessages.some((tmpMessage, index) => { if (tmpMessage.id === blockId) { tmpMessages[index].type = 'b'; return true; - } return false; + } + return false; }); return tmpMessages; }); @@ -58,7 +59,7 @@ export default function useChatSocket() { return { onReceiveMessage: handleIncomingMessage, - onReceiveBlock: handleIncomintBlock, + onReceiveBlock: handleIncomingBlock, onSendMessage: handleSendMessage, messages: chatMessages, }; From f2e2d43d0de67d2213f01b2ab04b4b3aeb6fb180 Mon Sep 17 00:00:00 2001 From: nimod7890 Date: Tue, 20 Aug 2024 15:08:51 +0900 Subject: [PATCH 2/7] =?UTF-8?q?fix:=20=EC=9D=B4=EB=AF=B8=20=EC=86=8C?= =?UTF-8?q?=EC=BC=93=EC=9D=B4=20=EC=97=B0=EA=B2=B0=EB=90=98=EC=96=B4?= =?UTF-8?q?=EC=9E=88=EB=8A=94=20=EC=83=81=ED=83=9C=EB=A9=B4=20=EC=83=88?= =?UTF-8?q?=EB=A1=9C=20=EC=97=B0=EA=B2=B0=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/src/components/chat/index.ts | 1 - packages/common/src/utils/socket.ts | 5 +++++ packages/user/src/hooks/socket/index.ts | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/common/src/components/chat/index.ts b/packages/common/src/components/chat/index.ts index 2732bb46..8ff0e7a2 100644 --- a/packages/common/src/components/chat/index.ts +++ b/packages/common/src/components/chat/index.ts @@ -30,4 +30,3 @@ export { default as BlockedChat } from './BlockedChat.tsx'; export { default as ChatList } from './ChatList.tsx'; export { default as Message } from './Message.tsx'; export { default as Notice } from './Notice.tsx'; - diff --git a/packages/common/src/utils/socket.ts b/packages/common/src/utils/socket.ts index e61e27fd..4d442685 100644 --- a/packages/common/src/utils/socket.ts +++ b/packages/common/src/utils/socket.ts @@ -27,6 +27,8 @@ export default class Socket { private token?: string | undefined | null = undefined; + isConnected: boolean = false; + constructor(url: string, token?: string | null) { let baseUrl = url; if (token) { @@ -47,10 +49,12 @@ export default class Socket { connect(callback?: (props: ConnectProps) => void) { this.client.onConnect = (options) => { + this.isConnected = true; callback?.({ isSuccess: true, options }); }; this.client.onStompError = (error) => { + this.isConnected = false; callback?.({ isSuccess: false, options: error }); }; @@ -63,6 +67,7 @@ export default class Socket { if (this.client.connected) { this.client.deactivate(); + this.isConnected = false; } } diff --git a/packages/user/src/hooks/socket/index.ts b/packages/user/src/hooks/socket/index.ts index fd97f7a1..f043c1e1 100644 --- a/packages/user/src/hooks/socket/index.ts +++ b/packages/user/src/hooks/socket/index.ts @@ -16,6 +16,7 @@ export default function useSocket() { const { onReceiveStatus, ...racingSocketProps } = racingSocket; useEffect(() => { + if (socketManager.getSocketClient().isConnected) return; socketManager.connectSocketClient({ token, onReceiveMessage, onReceiveStatus, onReceiveBlock }); }, [socketManager, token]); From d78b357fb89413a9c0f4164f8f09e1f02f7c67be Mon Sep 17 00:00:00 2001 From: nimod7890 Date: Tue, 20 Aug 2024 15:11:47 +0900 Subject: [PATCH 3/7] refactor: block chatting --- .../user/src/hooks/socket/useChatSocket.ts | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/packages/user/src/hooks/socket/useChatSocket.ts b/packages/user/src/hooks/socket/useChatSocket.ts index 76b51f7e..7e3d0dcb 100644 --- a/packages/user/src/hooks/socket/useChatSocket.ts +++ b/packages/user/src/hooks/socket/useChatSocket.ts @@ -24,20 +24,13 @@ export default function useChatSocket() { const handleIncomingBlock: SocketSubscribeCallbackType = useCallback( (data: unknown) => { - const { blockId } = data as { blockId: string }; - setChatMessages((prevMessages) => { - const tmpMessages = prevMessages.slice(); - tmpMessages.some((tmpMessage, index) => { - if (tmpMessage.id === blockId) { - tmpMessages[index].type = 'b'; - return true; - } - return false; - }); - return tmpMessages; - }); + const { id, blockId } = data as { id: string; blockId: string }; + + setChatMessages((prevMessages) => + prevMessages.map((message) => (message.id === blockId ? { id, type: 'b' } : message)), + ); }, - [chatMessages], + [setChatMessages], ); const handleSendMessage = useCallback( From fa592a946b73225f5fbde74700daac14f0d7d389 Mon Sep 17 00:00:00 2001 From: nimod7890 Date: Tue, 20 Aug 2024 15:12:02 +0900 Subject: [PATCH 4/7] =?UTF-8?q?design:=20=EB=B9=84=EC=86=8D=EC=96=B4=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=95=88=EB=82=B4=20=EB=AC=B8=EA=B5=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/src/components/event/chatting/inputArea/index.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/user/src/components/event/chatting/inputArea/index.tsx b/packages/user/src/components/event/chatting/inputArea/index.tsx index 5c180164..b9d14ad5 100644 --- a/packages/user/src/components/event/chatting/inputArea/index.tsx +++ b/packages/user/src/components/event/chatting/inputArea/index.tsx @@ -3,9 +3,8 @@ import { PropsWithChildren } from 'react'; export default function ChatInputArea({ children }: PropsWithChildren) { return (
- {/* Todo: 비속어 작성 횟수 불러오기 */}

- 비속어 혹은 부적절한 기대평을 5회 이상 작성할 경우, 댓글 작성이 제한됩니다. + 비속어 혹은 부적절한 기대평을 작성할 경우, 댓글 작성이 제한될 수 있습니다.

{children}
From afe30ef0ef0218eae421c9e6791c65ed2705b7e9 Mon Sep 17 00:00:00 2001 From: nimod7890 Date: Tue, 20 Aug 2024 15:15:13 +0900 Subject: [PATCH 5/7] =?UTF-8?q?remove:=20todo=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/user/src/components/shared/modal/fcfs/ResultStep.tsx | 1 - packages/user/src/hooks/query/useGetTeamTypeQuiz.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/packages/user/src/components/shared/modal/fcfs/ResultStep.tsx b/packages/user/src/components/shared/modal/fcfs/ResultStep.tsx index db3a1772..0b9d54b3 100644 --- a/packages/user/src/components/shared/modal/fcfs/ResultStep.tsx +++ b/packages/user/src/components/shared/modal/fcfs/ResultStep.tsx @@ -26,7 +26,6 @@ const IMAGE_URLS: Record = { end: '/images/fcfs/result/already-done.png', }; -/** TODO: 이벤트 마지막 날에는 '내일 퀴즈' 관련 문구 제거 */ const DESCRIPTIONS: Record< ResultStepType, { diff --git a/packages/user/src/hooks/query/useGetTeamTypeQuiz.ts b/packages/user/src/hooks/query/useGetTeamTypeQuiz.ts index c4d9a742..004dd9f4 100644 --- a/packages/user/src/hooks/query/useGetTeamTypeQuiz.ts +++ b/packages/user/src/hooks/query/useGetTeamTypeQuiz.ts @@ -5,7 +5,6 @@ import QUERY_KEYS from 'src/services/api/queryKey.ts'; export type Quiz = { id: number; question: string; choices: string[] }; export default function useGetTeamTypeQuizzes() { - // TODO: 빈 배열 내려올 경우 error handling const { data: quizzes } = useSuspenseQuery({ queryKey: [QUERY_KEYS.TEAM_TYPE_QUIZ], queryFn: () => http.get('/personality-test-list'), From 98c3869dcf59faa92408c638fb592cfbc5c36203 Mon Sep 17 00:00:00 2001 From: nimod7890 Date: Tue, 20 Aug 2024 17:19:50 +0900 Subject: [PATCH 6/7] =?UTF-8?q?feat:=20loader=EB=A1=9C=20kakao=20login=20r?= =?UTF-8?q?edirect=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/common/src/utils/socket.ts | 47 ++++++++----------- packages/user/src/pages/KakaoRedirectPage.tsx | 25 ---------- packages/user/src/pages/index.ts | 1 - packages/user/src/routes/loader/index.ts | 1 + .../user/src/routes/loader/kakao-redirect.ts | 23 +++++++++ .../user/src/routes/loader/share-redirect.ts | 2 +- packages/user/src/routes/router.tsx | 6 +-- packages/user/src/services/socket.ts | 27 +++++------ 8 files changed, 61 insertions(+), 71 deletions(-) delete mode 100644 packages/user/src/pages/KakaoRedirectPage.tsx create mode 100644 packages/user/src/routes/loader/kakao-redirect.ts diff --git a/packages/common/src/utils/socket.ts b/packages/common/src/utils/socket.ts index 4d442685..05a08819 100644 --- a/packages/common/src/utils/socket.ts +++ b/packages/common/src/utils/socket.ts @@ -15,11 +15,6 @@ export interface SendMessageProps { headers?: Record; } -export interface ConnectProps { - isSuccess: boolean; - options?: IFrame; -} - export default class Socket { private client: Client; @@ -47,21 +42,23 @@ export default class Socket { return stompClient; } - connect(callback?: (props: ConnectProps) => void) { - this.client.onConnect = (options) => { - this.isConnected = true; - callback?.({ isSuccess: true, options }); - }; + async connect(): Promise