feat: Add error handling for updating message by index
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.
This commit is contained in:
parent
0f75de02cb
commit
a96193bbf8
@ -355,10 +355,14 @@ export const updateMessageByIndex = async (
|
|||||||
index: number,
|
index: number,
|
||||||
message: string
|
message: string
|
||||||
) => {
|
) => {
|
||||||
|
try {
|
||||||
const db = new PageAssitDatabase()
|
const db = new PageAssitDatabase()
|
||||||
const chatHistory = (await db.getChatHistory(history_id)).reverse()
|
const chatHistory = (await db.getChatHistory(history_id)).reverse()
|
||||||
chatHistory[index].content = message
|
chatHistory[index].content = message
|
||||||
await db.db.set({ [history_id]: chatHistory.reverse() })
|
await db.db.set({ [history_id]: chatHistory.reverse() })
|
||||||
|
} catch(e) {
|
||||||
|
// temp chat will break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteChatForEdit = async (history_id: string, index: number) => {
|
export const deleteChatForEdit = async (history_id: string, index: number) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user