Skip to content

Commit be23ee4

Browse files
authored
Merge pull request #417 from PromptPlace/fix/#416
Fix/#416
2 parents df3a042 + d3864b1 commit be23ee4

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/chat/repositories/chat.repository.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export class ChatRepository {
9090
cursor: { message_id: cursor },
9191
}
9292
: {}),
93-
orderBy: { message_id: "asc" },
93+
orderBy: { message_id: "desc" },
9494
include: { attachments: true },
9595
}),
9696
// 해당 방의 전체 메시지 개수 조회
@@ -99,8 +99,11 @@ export class ChatRepository {
9999
}),
100100
]);
101101

102+
const hasNextPage = messages.length > limit;
103+
const actualMessages = hasNextPage ? messages.slice(0, -1) : messages;
104+
102105
return {
103-
messages,
106+
messages: actualMessages,
104107
totalCount,
105108
};
106109
}

src/chat/routes/chat.route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ router.post("/rooms", authenticateJwt, createOrGetChatRoom);
6969
* summary: 채팅방 상세 조회
7070
* description: >
7171
* 채팅방 상세 정보(상대 정보/차단 상태/메시지 목록/페이지 정보)를 조회합니다.<br/>
72-
* 메시지는 오래된 순(ASC)으로 반환되며, cursor 기반으로 과거 메시지를 추가로 불러올 수 있습니다.
72+
* 메시지는 최신순(DESC)으로 반환되며, cursor 기반으로 과거 메시지를 추가로 불러올 수 있습니다.
7373
* tags: [Chat]
7474
* security:
7575
* - jwt: []

0 commit comments

Comments
 (0)