Skip to content

Commit

Permalink
feat: Add error handling for updating message by index
Browse files Browse the repository at this point in the history
Adds error handling to the `updateMessageByIndex` function to prevent the temporary chat from breaking when an error occurs during the update process. This ensures a more robust and reliable experience for users.
  • Loading branch information
n4ze3m committed Nov 10, 2024
1 parent 0f75de0 commit a96193b
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,14 @@ export const updateMessageByIndex = async (
index: number,
message: string
) => {
try {
const db = new PageAssitDatabase()
const chatHistory = (await db.getChatHistory(history_id)).reverse()
chatHistory[index].content = message
await db.db.set({ [history_id]: chatHistory.reverse() })
} catch(e) {
// temp chat will break
}
}

export const deleteChatForEdit = async (history_id: string, index: number) => {
Expand Down

0 comments on commit a96193b

Please sign in to comment.