Skip to content

Commit 65f982b

Browse files
authored
feat : 알림 QA 수정 (#124)
1 parent b33b576 commit 65f982b

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/components/ToastItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default function ToastItem({ toastObj, index }: { toastObj: ToastObj; ind
2626

2727
const animation = `toast-blink ${toastObj.time}s ease-in-out forwards`;
2828
const toastStyle = twMerge(
29-
'fixed bottom-5 left-1/2 z-40 flex h-[40px] max-w-150 min-w-[300px] w-[80%] -translate-1/2 items-center justify-center rounded-lg caption-sb shadow-[0_1px_6px_rgba(200,200,200,0.2)]',
29+
'fixed bottom-5 left-1/2 z-50 flex h-[40px] max-w-150 min-w-[300px] w-[80%] -translate-1/2 items-center justify-center rounded-lg caption-sb shadow-[0_1px_6px_rgba(200,200,200,0.2)]',
3030
TOAST_POSITION[toastObj.position],
3131
TOAST_DESIGN[toastObj.toastType].style,
3232
);

src/hooks/useServerSentEvents.tsx

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const useServerSentEvents = () => {
1616
let reconnect: number | undefined;
1717

1818
const navigate = useNavigate();
19-
const recallCountRef = useRef(1);
19+
// const recallCountRef = useRef(1);
2020

2121
const accessToken = useAuthStore((state) => state.accessToken);
2222
const setAccessToken = useAuthStore((state) => state.setAccessToken);
@@ -77,22 +77,20 @@ export const useServerSentEvents = () => {
7777
handleOnMessage(event.data);
7878
};
7979

80-
sourceRef.current.onerror = () => {
81-
// 에러 발생시 해당 에러가 45초를 넘어서 발생한 에러인지, 401에러인지 판단할 수 있는게 없어서 그냥 에러 발생하면 reissue 넣는걸로 때움
82-
callReissue();
83-
closeSSE();
84-
recallCountRef.current += 1;
85-
console.log('SSE연결 에러 발생');
86-
87-
// 재연결 로직 추가 가능
88-
if (recallCountRef.current < 5) {
80+
sourceRef.current.onerror = (event) => {
81+
console.log(event);
82+
const errorEvent = event as unknown as { status?: number };
83+
if (errorEvent.status === 401) {
84+
callReissue();
85+
closeSSE();
8986
reconnect = setTimeout(connectSSE, 5000);
9087
} else {
91-
console.log('5회 이상 에러발생으로 구독기능 제거');
88+
closeSSE();
89+
reconnect = setTimeout(connectSSE, 5000);
9290
}
9391
};
9492
} catch (error) {
95-
console.error(error);
93+
console.log('catch문에서 에러 발생', error);
9694
}
9795
};
9896

0 commit comments

Comments
 (0)