Skip to content

Commit 285bcb4

Browse files
authored
Merge pull request #295 from prgrms-web-devcourse-final-project/feat/294-SSE-modal
[feat] SSE 연결 에러 모달 구현
2 parents f15e082 + 2f3e0a9 commit 285bcb4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/hooks/useSSE.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useAuthStore } from '@/store/authStore';
22
import { useChatStore } from '@/store/chatStore';
3+
import { useModalStore } from '@/store/modalStore';
34
import { useSheetStore } from '@/store/sheetStore';
45
import { EventSourcePolyfill } from 'event-source-polyfill';
56
import { useEffect, useRef } from 'react';
@@ -9,6 +10,7 @@ export const useSSE = () => {
910
const navigate = useNavigate();
1011
const { openSheet, closeSheet, setRequesterInfo, setChatConnectFail, closeAllSheets } =
1112
useSheetStore();
13+
const { openModal } = useModalStore();
1214
const { setCurrentChatRoomId } = useChatStore();
1315
const { isAuthenticated, accessToken } = useAuthStore();
1416
const eventSourceRef = useRef<EventSourcePolyfill | null>(null);
@@ -26,6 +28,11 @@ export const useSSE = () => {
2628
const connectSSE = () => {
2729
// 최대 재연결 횟수 초과 시 종료
2830
if (reconnectAttemptsRef.current >= 3) {
31+
openModal({
32+
title: '⚠️ 알림 연결이 불안정합니다.',
33+
message: '새로고침으로 복구할 수 있어요.',
34+
onConfirm: () => window.location.reload(),
35+
});
2936
console.warn('🚫 SSE: 최대 재연결 횟수(3번) 초과, 더 이상 재연결하지 않습니다.');
3037
return;
3138
}

0 commit comments

Comments
 (0)