Overnap
Builds for 1 pipeline passed in 8 minutes 2 seconds

라운드 끝날 때 정답 공개 추가

......@@ -24,10 +24,12 @@ export const Chat: React.FC<ChatProps> = (props) => {
socket.on('msg', handleChatData);
socket.on('msg', handleAcceptMessage);
socket.on('msg', handleFinishMessage);
return () => {
socket.off('msg', handleChatData);
socket.off('msg', handleAcceptMessage);
socket.on('msg', handleFinishMessage);
}
}, []);
......@@ -59,6 +61,16 @@ export const Chat: React.FC<ChatProps> = (props) => {
}
}, []);
const handleFinishMessage = useCallback((rawMessage: RawMessage) => {
if (rawMessage.type === MessageType.GAME_FINISH_ROUND) {
const message: ChatData = {
sender: 'SYSTEM',
message: 'The round is over!'
};
setChatLines(oldChatLines => [...oldChatLines, message]);
}
}, []);
return (
<div className={props.w}>
<div className={`${props.h} w-full py-2 rounded shadow flex flex-col overflow-y-scroll`}>
......
......@@ -56,7 +56,7 @@ export const GameBoard: React.FC<GameBoardProps> = ({ isInGame }) => {
}, [wordChosen]);
const handleAnswer = useCallback((rawMessage: RawMessage) => {
if (rawMessage.type === MessageType.GAME_ACCEPT) {
if (rawMessage.type === MessageType.GAME_ACCEPT || rawMessage.type === MessageType.GAME_FINISH_ROUND) {
const { answer } = rawMessage.message as { answer: string };
setWordChosen(answer);
}
......