Skip to content

Commit 9c51bcb

Browse files
committed
Fix: 강제 하단 스크롤 이동 버그 수정
1 parent 91a06ad commit 9c51bcb

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/hooks/chat/useBodyScrollControllerEffect.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export default (
4444
chatBodyRef.current.scrollTop = scrollTop;
4545
}, [chats]);
4646

47+
const lastChat = chats.length > 0 ? chats[chats.length - 1] : {};
4748
useEffect(() => {
4849
socketReady(() =>
4950
axios({
@@ -52,7 +53,7 @@ export default (
5253
data: { roomId },
5354
})
5455
);
55-
}, [chats.length]);
56+
}, ["time" in lastChat ? lastChat?.time : ""]);
5657

5758
useEffect(() => {
5859
const chatBody = chatBodyRef?.current;

src/hooks/chat/useSocketChatEffect.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ export default (
134134
}
135135
},
136136
updateListener: (_roomId: string) => {
137-
if (roomId !== _roomId) return;
137+
if (isExpired || roomId !== _roomId) return;
138138
fetchRoomInfo();
139139
},
140140
});
@@ -150,5 +150,5 @@ export default (
150150
isExpired = true;
151151
resetSocketEventListener();
152152
};
153-
}, [roomInfo, setChats, setDisplayNewMessage]);
153+
}, [roomInfo?._id, setChats, setDisplayNewMessage]);
154154
};

0 commit comments

Comments
 (0)