Skip to content

Commit

Permalink
Merge pull request #161 from venus-lion/staging
Browse files Browse the repository at this point in the history
Staging
  • Loading branch information
minjikimkim2222 authored Feb 13, 2025
2 parents a66b27e + cd9ba74 commit ff9e871
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
public class GroupChatroomCreationWorker {

private final RedisTemplate<String, Object> redisTemplate;
private final ThreadPoolExecutor threadPoolExecutor; // Consider using ExecutorService instead
private final ThreadPoolExecutor threadPoolExecutor;

private static final String GROUP_CHATROOM_QUEUE_KEY_PREFIX = "groupChatroomQueue:";

Expand All @@ -30,12 +30,10 @@ public Optional<Map<String, String>> requestChatroomCreation(String contentId) {
String queueKey = GROUP_CHATROOM_QUEUE_KEY_PREFIX + contentId;

Object memberIdObject = redisTemplate.opsForList()
.rightPop(queueKey, 10, TimeUnit.SECONDS); // Added timeout
.rightPop(queueKey, 10, TimeUnit.SECONDS);

if (memberIdObject instanceof String memberId) {
Map<String, String> resultMap = new HashMap<>();
resultMap.put(contentId, memberId);
return Optional.of(resultMap);
return makeResultMap(contentId, memberId);
}

return Optional.empty();
Expand All @@ -54,4 +52,10 @@ public Optional<Map<String, String>> requestChatroomCreation(String contentId) {
}
}

private Optional<Map<String, String>> makeResultMap(String contentId, String memberId) {
Map<String, String> resultMap = new HashMap<>();
resultMap.put(contentId, memberId);
return Optional.of(resultMap);
}

}
3 changes: 3 additions & 0 deletions fe/src/components/BookDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,8 @@ const styles = {
container: {
width: '100%',
fontFamily: 'Arial, sans-serif',
padding: '0',
margin: '0',
},
header: {
padding: '110px 20px',
Expand Down Expand Up @@ -1101,6 +1103,7 @@ const styles = {
},
section: {
marginBottom: '20px',
maxWidth: '100%',
},
sectionTitle: {
fontSize: '20px',
Expand Down
14 changes: 11 additions & 3 deletions fe/src/components/chat/Chat.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ const Chat = () => {
setStompClient(client);

return () => {
if (client.connected) client.deactivate();
if (client.connected){
client.deactivate();
}
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentUserId, personalChats, groupChats, selectedChat]);
Expand All @@ -270,19 +272,25 @@ const Chat = () => {
// type에 따라 적절한 API를 호출하여 채팅방 리스트 가져오기
if (type === 'group') {
response = await axiosInstance.get('/chat/group/rooms/my');

} else if (type === 'personal') {
response = await axiosInstance.get('/chat/oneOnOne');
}

// 전체 채팅방 리스트 상태에 저장
setChatrooms(response.data);


// chatId에 해당하는 채팅방 찾기
const chatRoom = response.data.find(room =>
type === 'group' ? room.groupChatroomId === chatId : room.roomId === chatId
);

console.log('@@ 선택된 방 : ' + JSON.stringify(chatRoom, null, 2));
if (type === 'group' && chatId) {
fetchGroupChatMembers(chatId);
}

console.log('@@ 선택된 방 : ' + JSON.stringify(chatRoom, null, 2));
if (chatRoom) {
setSelectedChat(chatRoom); // 찾은 채팅방 정보를 선택
}
Expand Down Expand Up @@ -474,7 +482,7 @@ const Chat = () => {
}

const handleChatMessage = (type, receivedMessage) => {
if (type === 'gruop') {
if (type === 'group') {
setGroupChats((prev) =>
prev.map((chat) =>
chat.roomId === receivedMessage.roomId
Expand Down
1 change: 1 addition & 0 deletions fe/src/pages/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@
/*position: relative;*/
/*position: relative;*/
border-radius: 8px;
overflow: hidden; /* 이미지가 영역 밖으로 나가지 않도록 */
/*height: 350px;*/
}

Expand Down

0 comments on commit ff9e871

Please sign in to comment.