Skip to content

Commit

Permalink
🐛 fix: fix a bug that export a session without messages
Browse files Browse the repository at this point in the history
  • Loading branch information
arvinxx committed Nov 30, 2023
1 parent 5d2b750 commit 8e84f35
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/database/models/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ class _MessageModel extends BaseModel {
return count === 0;
}

async queryBySessionId(sessionId: string) {
return this.table.where('sessionId').equals(sessionId).toArray();
}

private mapChatMessageToDBMessage(message: ChatMessage): DB_Message {
const { extra, ...messageData } = message;

Expand Down
2 changes: 1 addition & 1 deletion src/services/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class ConfigService {
const session = this.getSession(id);
if (!session) return;

const messages = await messageService.getMessages(id);
const messages = await messageService.getAllMessagesInSession(id);
const topics = await topicService.getTopics({ sessionId: id });

const config = createConfigFile('singleSession', { messages, sessions: [session], topics });
Expand Down
4 changes: 4 additions & 0 deletions src/services/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export class MessageService {
return MessageModel.delete(id);
}

async getAllMessagesInSession(sessionId: string) {
return MessageModel.queryBySessionId(sessionId);
}

async updateMessageContent(id: string, content: string) {
return MessageModel.update(id, { content });
}
Expand Down

0 comments on commit 8e84f35

Please sign in to comment.