Skip to content

Commit 62dc8f3

Browse files
Merge pull request #1191 from woowacourse-teams/FE/test
[FE] 🔖 버그 수정 내역 deploy
2 parents 0d4ae01 + a814e3f commit 62dc8f3

File tree

7 files changed

+35
-18
lines changed

7 files changed

+35
-18
lines changed

frontend/src/apis/websocket/websocket.ts

+23-6
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,32 @@ export const getConnection = () => {
77
};
88

99
export const subscribeTopic = <T>(client: Client | null, destination: string, handler: (body: T) => void) => {
10-
if (!client?.connected) {
11-
console.error('웹소켓 연결에 실패했습니다.');
10+
if (!client) {
11+
console.error('웹소켓 클라이언트가 없습니다.');
1212
return;
1313
}
1414

15-
client.subscribe(destination, (message: Message) => {
16-
const body: T = JSON.parse(message.body);
17-
handler(body);
18-
});
15+
const subscribe = () => {
16+
if (client.connected) {
17+
client.subscribe(destination, (message: Message) => {
18+
const body: T = JSON.parse(message.body);
19+
handler(body);
20+
});
21+
} else {
22+
console.error('웹소켓 연결에 실패했습니다.');
23+
}
24+
};
25+
26+
client.onConnect = () => {
27+
console.log('웹소켓 연결이 성공적으로 재설정되었습니다.');
28+
subscribe();
29+
};
30+
31+
client.onDisconnect = () => {
32+
console.warn('웹소켓 연결이 해제되었습니다.');
33+
};
34+
35+
subscribe();
1936
};
2037

2138
export const publishMessage = (client: Client | null, destination: string, contents?: object) => {

frontend/src/components/PairRoom/PairRoleCard/PairRoleCard.styles.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ const RoleBox = styled.div`
3232
export const DriverBox = styled(RoleBox)`
3333
background: linear-gradient(
3434
180deg,
35-
${({ theme }) => theme.color.secondary[50]},
36-
${({ theme }) => theme.color.secondary[200]}
35+
${({ theme }) => theme.color.primary[50]},
36+
${({ theme }) => theme.color.primary[100]}
3737
);
3838
`;
3939

@@ -72,19 +72,19 @@ const RoleLabel = styled.div`
7272
`;
7373

7474
export const DriverLabel = styled(RoleLabel)`
75-
background-color: ${({ theme }) => theme.color.secondary[500]};
75+
background-color: ${({ theme }) => theme.color.primary[600]};
7676
`;
7777

7878
export const NavigatorLabel = styled(RoleLabel)`
79-
background-color: ${({ theme }) => theme.color.primary[600]};
79+
background-color: ${({ theme }) => theme.color.secondary[500]};
8080
`;
8181

8282
export const DriverText = styled.p`
8383
overflow: hidden;
8484
8585
max-width: 10rem;
8686
87-
color: ${({ theme }) => theme.color.secondary[900]};
87+
color: ${({ theme }) => theme.color.primary[900]};
8888
text-overflow: ellipsis;
8989
white-space: nowrap;
9090
`;
@@ -94,7 +94,7 @@ export const NavigatorText = styled.p`
9494
9595
max-width: 10rem;
9696
97-
color: ${({ theme }) => theme.color.primary[900]};
97+
color: ${({ theme }) => theme.color.secondary[900]};
9898
text-overflow: ellipsis;
9999
white-space: nowrap;
100100
`;

frontend/src/hooks/PairRoom/useCategorySocket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const useCategory = (defaultCategories: Category[]) => {
3131
client.unsubscribe(`/topic/${accessCode}/category`);
3232
}
3333
};
34-
}, [client]);
34+
}, [client, isConnected]);
3535

3636
return { categories: [DEFAULT_CATEGORY, ...(categories || [])] };
3737
};

frontend/src/hooks/PairRoom/usePairRoomStatusSocket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const usePairRoomStatusSocket = (defaultStatus: PairRoomStatus) => {
3636
client.unsubscribe(`/topic/${accessCode}/pair-room/status`);
3737
}
3838
};
39-
}, [client]);
39+
}, [client, isConnected]);
4040
};
4141

4242
export default usePairRoomStatusSocket;

frontend/src/hooks/PairRoom/useReferenceSocket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const useReference = (defaultReferences: Reference[]) => {
2222
client.unsubscribe(`/topic/${accessCode}/reference-link`);
2323
}
2424
};
25-
}, [client]);
25+
}, [client, isConnected]);
2626

2727
return { references };
2828
};

frontend/src/hooks/PairRoom/useTimerSocket.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ const useTimer = (defaultTime: number, defaultTimeLeft: number, onTimerStop: ()
6969

7070
case TimerStatus.RUNNING:
7171
setIsActive(true);
72-
addToast({ status: 'WARNING', message: '타이머가 진행 중입니다.' });
72+
// addToast({ status: 'WARNING', message: '타이머가 진행 중입니다.' });
7373
break;
7474

7575
case TimerStatus.PAUSE:
@@ -120,7 +120,7 @@ const useTimer = (defaultTime: number, defaultTimeLeft: number, onTimerStop: ()
120120
window.removeEventListener('beforeunload', handleBeforeUnload);
121121
unsubscribeTopics();
122122
};
123-
}, [client]);
123+
}, [client, isConnected]);
124124

125125
return {
126126
duration: durationRef.current,

frontend/src/hooks/PairRoom/useTodoSocket.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const useTodo = (defaultTodos: Todo[]) => {
2323
client.unsubscribe(`/topic/${accessCode}/todo`);
2424
}
2525
};
26-
}, [client]);
26+
}, [client, isConnected]);
2727

2828
return { todos };
2929
};

0 commit comments

Comments
 (0)