Refactor message appending logic in useMessageOption hook

This commit is contained in:
n4ze3m
2024-03-14 23:43:58 +05:30
parent 00bd19374a
commit 5b04e55a03
3 changed files with 130 additions and 93 deletions

View File

@@ -286,11 +286,10 @@ export const updateHistory = async (id: string, title: string) => {
}
export const removeMessageUsingHistoryId = async (history_id: string) => {
// remove the last message
const db = new PageAssitDatabase()
const chatHistory = await db.getChatHistory(history_id)
const newChatHistory = chatHistory.slice(0, -1)
await db.db.set({ [history_id]: newChatHistory })
chatHistory.shift()
await db.db.set({ [history_id]: chatHistory })
}