fix: ensure topic is created if not found in loadTopicMessagesThunk

* Added logic to create a new topic with an empty messages array if the specified topic does not exist in the database.
This commit is contained in:
kangfenmao 2025-05-14 21:53:28 +08:00
parent e00f03db2b
commit fb548ca20a

View File

@ -721,6 +721,11 @@ export const loadTopicMessagesThunk =
try {
const topic = await db.topics.get(topicId)
if (!topic) {
await db.topics.add({ id: topicId, messages: [] })
}
const messagesFromDB = topic?.messages || []
if (messagesFromDB.length > 0) {