better deep clone of message object. re-initalize ttsLastMessage after changing chats

This commit is contained in:
smirgol 2023-11-08 19:08:42 +01:00
parent 91266c831c
commit 4f0935c494
1 changed files with 2 additions and 1 deletions

View File

@ -145,7 +145,7 @@ async function moduleWorker() {
} }
// clone message object, as things go haywire if message object is altered below (it's passed by reference) // clone message object, as things go haywire if message object is altered below (it's passed by reference)
const message = JSON.parse(JSON.stringify(chat[chat.length - 1])) const message = structuredClone(chat[chat.length - 1])
// if last message within current message, message got extended. only send diff to TTS. // if last message within current message, message got extended. only send diff to TTS.
if (ttsLastMessage !== null && message.mes.indexOf(ttsLastMessage) !== -1) { if (ttsLastMessage !== null && message.mes.indexOf(ttsLastMessage) !== -1) {
@ -646,6 +646,7 @@ export function saveTtsProviderSettings() {
async function onChatChanged() { async function onChatChanged() {
await resetTtsPlayback() await resetTtsPlayback()
await initVoiceMap() await initVoiceMap()
ttsLastMessage = null
} }
async function onChatDeleted() { async function onChatDeleted() {