Skip to content

Commit e0d650f

Browse files
authored
Merge pull request #128 from kjiyun/chat
#127 Fix: 채팅 좋아요 여부 확인 로직 변경
2 parents afef246 + f8965d6 commit e0d650f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/main/java/com/memesphere/domain/chat/converter/ChatConverter.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import com.memesphere.domain.chat.dto.response.ChatResponse;
88
import com.memesphere.domain.user.entity.User;
99

10+
import java.util.Objects;
1011
import java.util.stream.Collectors;
1112

1213
public class ChatConverter {
@@ -21,15 +22,18 @@ public static Chat toChat(MemeCoin memeCoin, ChatRequest chatRequest, User user)
2122
}
2223

2324
public static ChatResponse toChatResponse(Chat chat, User user) {
25+
boolean isLiked = chat.getChatLikeList().stream()
26+
.anyMatch(chatLike -> Objects.equals(chatLike.getUser().getId(), user.getId()));
2427

28+
if (chat.getChatLikeList().isEmpty()) {}
2529
return ChatResponse.builder()
2630
.id(chat.getId())
2731
.message(chat.getMessage())
2832
.memeCoin(chat.getMemeCoin().getName())
2933
.likes(chat.getChatLikeList().size())
3034
.createdAt(chat.getCreatedAt())
3135
.nickname(chat.getUser().getNickname())
32-
.isLiked(chat.getChatLikeList().contains(user))
36+
.isLiked(isLiked)
3337
.build();
3438
}
3539

0 commit comments

Comments
 (0)