Skip to content

Commit cc2cb2e

Browse files
committed
refactor: 주석 삭제
1 parent 5cb93e8 commit cc2cb2e

1 file changed

Lines changed: 5 additions & 25 deletions

File tree

frontend/src/components/ChatRoom.tsx

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ interface ChatRes {
4141
interface ServerChatItem {
4242
id: number
4343
member_id: number
44-
member_name: string // 서버 응답에 이 필드가 포함되어야 가장 좋습니다.
44+
member_name: string
4545
content: string
4646
created_at: string
4747
}
@@ -90,16 +90,14 @@ function ChatRoom({ chatRoomId, postTitle, onBack }: ChatRoomProps) {
9090
const token = localStorage.getItem("accessToken");
9191
if (token) {
9292
const payload = decodeJwtPayload(token);
93-
// Assuming the memberId is stored in a claim named 'memberId' or 'sub' (standard for subject)
94-
// Adjust 'memberId' or 'sub' based on your actual JWT payload structure
9593
if (payload && payload.memberId) {
9694
setCurrentMemberId(Number(payload.memberId));
97-
} else if (payload && payload.sub) { // Fallback to 'sub' if 'memberId' is not present
95+
} else if (payload && payload.sub) {
9896
setCurrentMemberId(Number(payload.sub));
9997
}
10098
} else {
10199
}
102-
}, []); // Run once on component mount
100+
}, []);
103101

104102
const scrollToBottom = () => {
105103
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" })
@@ -152,7 +150,7 @@ function ChatRoom({ chatRoomId, postTitle, onBack }: ChatRoomProps) {
152150
const mappedResult: ChatRes[] = resultFromServer.map((item) => ({
153151
id: item.id,
154152
memberId: item.member_id,
155-
memberName: item.member_name, // 초기 로딩 시에는 서버가 이름을 줄 것으로 기대
153+
memberName: item.member_name,
156154
content: item.content,
157155
createdAt: new Date(item.created_at),
158156
}));
@@ -247,7 +245,7 @@ function ChatRoom({ chatRoomId, postTitle, onBack }: ChatRoomProps) {
247245
const mappedData: ChatRes = {
248246
id: serverData.id,
249247
memberId: serverData.member_id,
250-
memberName: memberName, // 수정된 이름 사용
248+
memberName: memberName,
251249
content: serverData.content,
252250
createdAt: new Date(serverData.created_at),
253251
};
@@ -292,8 +290,6 @@ function ChatRoom({ chatRoomId, postTitle, onBack }: ChatRoomProps) {
292290
return;
293291
}
294292

295-
// 메시지 전송 시에는 chatMemberName을 보내지 않습니다.
296-
// 서버가 memberId를 기반으로 조회하여 응답 메시지에 포함시켜야 합니다.
297293
const messageToSend = { memberId: currentMemberId, content: newMessage };
298294
const destination = `/pub/${chatRoomId}/message`;
299295
try {
@@ -423,22 +419,6 @@ function ChatRoom({ chatRoomId, postTitle, onBack }: ChatRoomProps) {
423419
<h3 className="font-bold text-md text-[#1877f2]">참여중인 멤버</h3>
424420
</div>
425421

426-
{/* TODO: 상태 변경 기능 보수 */}
427-
{/* {currentUserParticipant && (
428-
<div className="p-4 border-b border-[#e4e6eb] bg-[#f7f9fb]">
429-
<div className="text-xs font-bold uppercase text-[#65676B] mb-2">내 상태</div>
430-
<select
431-
className="w-full p-2 bg-white border border-[#e4e6eb] rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-[#1877f2] focus:border-transparent"
432-
value={currentUserParticipant.status || "ONLINE"}
433-
onChange={(e) => handleSelfStatusChange(e.target.value)}
434-
>
435-
<option value="ONLINE">ONLINE</option>
436-
<option value="OFFLINE">OFFLINE</option>
437-
<option value="LEFT">LEFT (나감)</option>
438-
</select>
439-
</div>
440-
)} */}
441-
442422
<div className="flex-grow p-2">
443423
{loadingParticipants && (
444424
<div className="flex justify-center items-center h-20">

0 commit comments

Comments
 (0)